I am making a game where if you stand on a convener (that's supposed to be water) you keep taking damage until you step onto another block. I've tried a bunch of different codes and none of them have seemed to work correctly. Does anyone have ideas?
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.

3 comments
https://scriptinghelpers.org/blog/posting-good-questions-and-answers-on-scripting-helpers
plz make attempt ;C
You need code