How to set a variable directly, after initializing it?

In coding, we can increase or decrease our variable after we have made our variable, but we cannot directly make a number for our variable, I think this is a big problem for advanced code writers or I have not seen this code. What I want to do is when I press the designated key for a character, then when I press the up button, I want it to accelerate, and when I do not press the key I have determined, I want my character to reach the old speed

1 Like

Hi @ekrem_kozan,

You can use the set variable CoBlock to directly make a number for your variable, for example:

This initializes the variable to 50, then immediately changes it to 100.

Of course, you can also set this via change variable by CoBlock by a positive or negative number too. Both ways provide a solution for the problem you’re wanting to solve.

Hope this helps! Let me know if you have any further questions about this. If this solves your problem, please mark this post as the Solution.

Many thanks,
Geoff @ TechLeap

1 Like