✓ Accepted answer
Hello! My name is BlackOrange3343 and I will be helping you today!
#Problem:#
So the reason the debounce isn't actually working is that each time the event RenderStepped runs, it creates a new local variable called debounce. This means it will indeed spam.
One more issue is you did not define RunService. (Maybe you have but didn't show it)
#Solution:#
The solution is very simple. All you have to do is move local debounce = false outside of the event!
local RunService = game:GetService('RunService')
local debounce = false
RunService.RenderStepped:Connect(function()
if not debounce and not character:FindFirstChild("UpperTorso") then
debounce = true
beam.Enabled = false
print(head.Parent.Name .. " has died")
wait(5)
debounce = false
end
end)
note that some of the variables inside the event are not defined. Make sure to define them and everything should work!
Best of luck developer and I hope this helped!
BlackOrange3343
1 comment
You basically put it in a loop, because RenderStepped fires 60 times every second, and your print should run once every 5 seconds.