local debounce = false
--if dead is true
script.Parent.Touched:Connect(function(hit)
print("touched")
if script.Parent.Dead.Value == true and not debounce then
debounce = true
print("dead now")
script.Parent.Parent:Destroy()
end
end)
--
while true do
wait()
--gradually decrease oxygen
delay(0.2,function()
if script.Parent.Oxygen.Value <= 100 then
script.Parent.Oxygen.Value = script.Parent.Oxygen.Value - 1
end
end)
--
--change color if oxygen is getting low, kill if its 0
if script.Parent.Oxygen.Value < 50 and script.Parent.Oxygen.Value > 1 then
script.Parent.BrickColor = BrickColor.new("New Yeller")
end
if script.Parent.Oxygen.Value >= 51 then
script.Parent.BrickColor = BrickColor.new("Lime green")
end
if script.Parent.Oxygen.Value <= 0 then
script.Parent.Dead.Value = true
end
--
--turn death on if hp is 0
if script.Parent.Health.Value <= 0 then
script.Parent.Dead.Value = true
script.Parent.BrickColor = BrickColor.new("Really black")
end
--
end
I have different things put together in one script because I want to keep everything neat and tidy. but some things like delay() wont work, another example is if I move the touched function down to the bottom it wont work either.
