So I’m making a fighting game with simple guns, no ray cast or anything, but I need to add a debounce to my gun system, the problem is I don’t know where to put it. I got the system from a tutorial and I’m new to scripting. Here is the script.
local debounce = false
local fireRate = 2 -- (time between each shot)
script.Parent.RemoteEvent.OnServerEvent:Connect(function(player, target)
if debounce == false then
target.Humanoid:TakeDamage(30)
task.wait(fireRate)
debounce = false
end
end)
Also small little mistake, you need debounce = true in it too
so heres the updated:
local debounce = false
local fireRate = 2 -- (time between each shot)
script.Parent.RemoteEvent.OnServerEvent:Connect(function(player, target)
if debounce == false then
debounce = true
target.Humanoid:TakeDamage(30)
task.wait(fireRate)
debounce = false
end
end)