So i need the loop to keep damaging the player every let's say .5 seconds while he is touching a certain part, and when he stops for it to stop as well. I am not asking for someone to make the whole script for me, i need someone to help me make it. I'd really appreciate if someone told me what to do and maybe linked me the developer wiki article connected to that.
✓ ANSWER ACCEPTED
How do i make a loop that repeats a certain action while the character is touching a certain part?
1 answer
✓ Accepted answer
You could do something like this.
local part = workspace.BRICK
local touch = false -- Debounce
part.Touched:Connect(function(hit)
touch = true
while touch do
wait(.5) -- Delay
-- Code here
part.TouchEnded:Connect(function()
touch = false
end)
end
end)
If this helped you please mark as answered :)
This discussion is preserved as it was. New answers, comments, and votes are closed.

1 comment
Thanks, works just as intendet :D