Hi, my debounce is not working correctly and I am not sure why. Anyone know? Continuously prints true
local debounce = true
regen.Touched:Connect(function(hit)
if debounce then
print("Touching ",debounce )
local debounce = false
local player = game:GetService("Players"):GetPlayerFromCharacter(hit.Parent)
if player then
--code
end
end
wait(5)
debounce = true
end)
local debounce = true
regen.Touched:Connect(function(hit)
if debounce then
print("Touching ", debounce)
debounce = false
local player = game:GetService("Players"):GetPlayerFromCharacter(hit.Parent)
if player then
--code
end
task.wait(5)
debounce = true
end
end)
local players = game:GetService("Players")
local debounce = true
regen.Touched:Connect(function(hit)
if hit.Parent:FindFirstChildOfClass("Humanoid") and debounce then
debounce = false
print(`Touching {debounce}`)
local player = players:GetPlayerFromCharacter(hit.Parent)
if player then
--code
end
task.wait(5)
debounce = true
end
end)
I have no idea what’s different compared to the change I made, but for some reason it works. Thanks!
–Oh wait I redefined it as local. lol that was a bit silly of me