So I'm making a simulator in Roblox, and I'm trying to add a cool down to a gun, and I don't know how.
script.Parent.Lift.OnServerEvent:Connect(function() local energy = game.Players[script.Parent.Parent.Name].leaderstats.Energy energy.Value = energy.value + 1 end)
Hello!
You can add a cooldown by adding a debounce.
local debounce = false local CooldownTime = 1 script.Parent.Lift.OnServerEvent:Connect(function() if not debounce then debounce = true local energy = game.Players[script.Parent.Parent.Name].leaderstats.Energy energy.Value = energy.value + 1 wait(CooldownTime) debounce = false end end)
I made this on the editor on this site if it's messy my bad.