I am not good at all at scripting and really need to know how to make cool downs. How do you make a cooldown for this?
Code:
local UserInputService = game:GetService("UserInputService") UserInputService.InputBegan:Connect(function(input) if input.KeyCode == Enum.KeyCode.F then game.ReplicatedStorage.TimeStop:FireServer() end end)
There are more complex and secure ways to create a cooldown, but one of the simplest would be creating a Debounce. It basically stops the event from firing unless the Debounce is set the respective value.
local OnCooldown = false -- It currently isn't on cooldown. local UserInputService = game:GetService("UserInputService") UserInputService.InputBegan:Connect(function(input) if input.KeyCode == Enum.KeyCode.F and not OnCooldown then OnCooldown = true -- Setting the Cooldown to true, so it can't fire again. game.ReplicatedStorage.TimeStop:FireServer() wait(1) -- How long you want the Cooldown to be, I have it set to 1 second. OnCooldown = false -- No longer on Cooldown. end end)