Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

How to make this persistent damage?

What I am asking, is if every two seconds you're standing on this, it takes away 10 health.

2 Seconds = 10 damage

function onTouched(hit)
	local humanoid = hit.Parent:findFirstChild("Humanoid")
	if (humanoid ~= nil) then
		humanoid.Health = humanoid.Health - 10
	end
end

script.Parent.Touched:connect(onTouched)

2 comments

0

I'd recommend adding debounce and setting it to two seconds.

0

That'd work?

1 answer

if (humanoid ~= nil) then while true do humanoid.Health = humanoid.Health - 2 wait(2) end

If you want to stop at a certain point then do the for i = 1,5

This discussion is preserved as it was. New answers, comments, and votes are closed.