UIS.InputBegan:Connect(function(Key)
if Key.KeyCode == Enum.KeyCode.F then
print("Pressed F")
task.wait(2)
print("Ended")
end
end)
Let’s say I spam F 8 times. Pressed F will get printed 8 times but Ended will also get printed 8 times.
If I press F while the script is playing then the script doesn’t reset.
There will now be 8 scripts running at the same time.
That’s why Ended is printed out 8 times.
Is there a way to reset the script? (Make Ended print out once even though you pressed F multiple times)
One way to do it would be to make the code in a function at the beginning of your script where you declare vaiables. Then have a control variable that is either true or false. if the variable is false you will run the function and if its true you will not run the function. when the function is ran set the variable to true and when its completed you set the variable to false. im not that good at explaining so let me know if you have questions