In my game I have attacks that the player uses to fight other players but I can't figure out how to do damage without the script doing the damage constantly instead of once or how to get damage to last over time when touching a part like 5 damage every second for instance. Could anyone point me in the right direction?
local Part = script.Parent local Damage = 5 local Seconds = 2 -- Player takes 5 damage every two seconds local Ticks = 5 -- This determines how many times the Player will take damage function DAMAGE_PLAYER(humanoid) humanoid:TakeDamage(Damage) wait(Seconds) end function TOUCHED(hit) if hit and hit.Parent:FindFirstChild('Humanoid') then local humanoid = hit.Parent:FindFirstChild('Humanoid') for ticks = 1, Ticks do DAMAGE_PLAYER(humanoid) end end end Part.Touched:connect(TOUCHED)