So this is a basic take damage script. Because of how often players can hit stuff, even 1 damage is op without a ting/debounce. Well so i put in one, and the results are funky.. I upped the ting time for testing reasons. I got hit once, waited 20 seconds, and then I was able to get hit as many times as i wanted, as if ting didn't exist anymore after the first touch.. I even printed ting and it always came back as 1..
Anyone know why?
local touch = script.Parent:FindFirstChild("Head")
local ting = 0
function dmg(hit)
if ting == 0 then
ting = 1
if hit.Parent ~= nil then
local hum = hit.Parent:findFirstChild("Humanoid")
if hum ~= nil then
hum.Health = hum.Health - math.random(12,20)
end
end
end
wait(20) -- Here is my wait between activations
ting = 0
end
touch.Touched:connect(dmg)
