if input.KeyCode == Enum.KeyCode.F then
-- do something
end
How do i make it so players arent able to spam the F keycode?
if input.KeyCode == Enum.KeyCode.F then
-- do something
end
How do i make it so players arent able to spam the F keycode?
You can just introduce a debounce variable and a cooldown. If the player inputs the letter, the script will check if the debounce is false before it gets set to true. After that, you can use wait() or task.wait() for the cooldown, until the debounce variable gets set back to false again.
pretty common code structure for cooldown is
local cd = false
UIS.InputBegan -- event stuff
if input.KeyCode == Enum.KeyCode.F and not cd then
cd = true
-- do something
task.wait(1)
cd = false
end
This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.