Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

How would i make a timed key press?

Recently I've been motivated to do some scripting and one question that has been lingering in my head for years is how I would make it so that you would have to press a key within a certain amount of time or a value would go back to say 0.

An example would be

Combo is a number value

Combo == 0

Player presses E key

Combo now == 1

Player doesn't press the E key or a different key within the time limit of 2 seconds

Combo is now == 0

But if the Player presses the E key again the time limit resets and Player now has another 2 seconds

Combo is now == 2

4 comments

0

i think u just answered ur own question

0

But how would i actually code that?

0

Use a function to see if a numb value has changed, the moment it has, wait however long. Store the numb value as a variable. At the end of the time, compare the new numb value and the stored. If the same, set numb value to 0, else add one

0

Alrighty

1 answer

Check the tick() and time() functions. Example use time() at the start of the action, if time equals something and action happened then do something.

This discussion is preserved as it was. New answers, comments, and votes are closed.