I have a part that will lose health slowly to a player but would like it to continue until another part is touched. I have a part that is scripted with the slow damage to the player. I would like to be able for that script to stop once another part is touched. Any advice would be appreciated.
COMMUNITY QUESTION
How to have player slowly lose health until another part is touched?
1 answer
I don't know if this will work or not but you should try it
--put this script in the part that will reduce your health
local value = --create a Value in ReplicatedStorage
function onTouched(hit)
if hit.Parent:findFirstChild("Humanoid") then
while value ~= 1 do
hit.Parent.Humanoid:TakeDamage(1)
end
end
end
script.Parent.Touched:Connect(onTouched)
Make another script in the part that will stop you from losing health
local value = -- put the value you made here
function onTouched(hit)
if hit.Parent:findFirstChild("Humanoid") then
value = 1
hit.Parent.Humanoid.Health = 100 -- if you want the part to heal you, then put this, or else, delete this line.
end
end
script.Parent.Touched:Connect(onTouched)
This discussion is preserved as it was. New answers, comments, and votes are closed.

1 comment
It appears you may be new to this site. We cannot just give you code and move on with our ways; our goal is to help you, not to spoonfeed you. If you have an attempt at this, we may assist you.