Its almost as if the wait(2) is invisible. I posted the same question yesterday and got things about debounces but none of the solutions worked. Please help. I'm not that knowledgeable, but my hypothesis is that it is waiting wait(2), but it is constantly searching for hum so the code is running constantly and dealing damage constantly. My code:
local rarm = script.Parent:FindFirstChild("RightUpperArm")
local larm = script.Parent:FindFirstChild("LeftUpperArm")
function dmg(hit)
if hit.Parent ~= nil then
local hum = hit.Parent:findFirstChild("Humanoid")
while hum ~= nil do
print("phase1")
hum.Health = hum.Health -10
print("phase2")
wait (2)
if hum ~= true then
break
end
end
end
end
rarm.Touched:connect(dmg)
larm.Touched:connect(dmg)

1 comment
Are you using a wait on line 7? Because its constantly checking wether the humanoid is not equal to nil and so it wont move to the next part of the script. Make sure you add a wait below line 7.