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

How Do You Make a Brick Kill You Over Time?

2 answers

you could make a script like this if you put it inside of the water

local Touching = false
local TouchedBy = nil
local Debounce = false

script.Parent.Touched:connect(function(t)
Touching = true
if t.Parent:FindFirstChild("Humanoid") ~= nil then
TouchedBy = t.Parent
end
end

script.Parent.TouchEnded:connect(function()
Touching = false
end

while wait() do
if Touching == true and TouchedBy ~= nil and Debounce == false then
	Debounce = true
	TouchedBy.Humanoid.Health = TouchedBy.Humanoid.Health - 10 -- the amount of damage you want it to deal
	wait(1) -- the time you want it to wait before dam damaging again
	Debounce = false
end
end


local Damage = 5
local Seconds = 1 -- so every 1 second, it damages the player by 5

script.Parent.Touched:connect(function(hit)
	if hit and hit.Parent:FindFirstChild('Humanoid') then 
		local humanoid = hit.Parent:FindFirstChild('Humanoid')
		humanoid:TakeDamage(Damage)
		wait(Seconds)
	end
end)

2 comments

1

Connect not connect. learn

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