Is there a way to trigger a command when a key is lifted?

I'm currently in the midst of remaking the NES Super Mario Brothers, and although I have found answers to nearly everything I needed, this one I seem to be stuck on.

When I make Mario sprint, I want his speed to increase gradually, and when a key is lifted I'd like the speed to decrease gradually. Decreasing is my problem because I couldn't make a make-shift trigger for when a key is lifted.

I'm doing as a passion project, and I want it to be as a accurate as possible, thank you for any help you'd be able to provide

Side note: I'd need the "when key lifted" type block directly under the "When key pressed"

Does this help you?

untitled script pic - 2023-09-16T133704.154

Trying to use this made me realise how unfamiliar I am with the "Say" command lol. How do I make something pick up on that?

I may have not accounted for certain things. I need them to trigger for a short period of time only to slow down the player, and I also need them not to interfere with the other inputs, like jumping. Any other ideas?

If you publish your project, it'll be a lot easier to help you out as we can then see all that is going on :slight_smile:

Alright, but a heads up, it has a lot going on. Just ask if you want to know where something is, or what something does.

OK :slight_smile:

What key are you using to sprint?
Ignore that

I see that you have this to move left/right

I can't see any increasing going on

What you need to do is basically change your horizontal movement so that its like your vertical movement - e.g. has acceleration in it rather than just scroll a fixed number of units

Regardless - hopefully some of the Snappers that have written things like this will be come along to give some proper advice :slight_smile:

Update for everyone here! I did eventually find a solution! (also I didn't have any increasing, at the time I thought it was necessary, but honestly it looked bad otherwise.) It won't let me include an image for whatever reason, but for controlling Mario I used 3 main variables; Xv is Velocity on the X axis, walk speed it how fast it increases speed, and max walk speed is the fastest it'll go.
At the top of your script set your walk speed and maximum walk speed. Make it so if a certain button is pressed, in my case right arrow/D, it'll run an if statement seeing if Xv is less than the max walk speed, and if it is have it "Change Xv by Walk speed" (if you wanna have a moving sprite animation, put the animation chain under another if statement that is inside directly under the other one checking if Xv is not equal to 0. For left just copy the same thing, but make the less than a greater than comparison.

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.