I am making a space theme game. When I go out I lose oxygen and start to suffocate and my screen turns blurry, like I am passing out. The good news it works very good even in an online game, the bad news I dont know how to prevent a player from dying after he touches a part that "has oxygen".
local blur = game.Lighting.Blur script.Parent.Touched:connect(function() blur.Enabled = false end) script.Parent.TouchEnded:connect(function() blur.Enabled = true blur.Size = 2 wait(0.3) blur.Size = 4 wait(0.3) blur.Size = 6 wait(0.3) blur.Size = 8 wait(0.3) blur.Size = 10 wait(0.3) blur.Size = 12 wait(0.3) blur.Size = 14 end) script.Parent.TouchEnded:connect(function(hit) wait(5) if hit and hit.Parent and hit.Parent:FindFirstChild("Humanoid") then hit.Parent.Humanoid.Health = 0 end end)
I already made a script of killing a player when he untouches a part, but when I touch the part again he still dies. Can anyone help me? How to stop run a line of code to prevent what will happen next?
-- The Bool Value setup game:GetService("Players").PlayerAdded:Connect(function(plr) local touchedPart = Instance.new("BoolValue", plr) touchedPart.Name = "TouchedOxygen" -- Change the name touchedPart.Value = false -- Change to true when they step on the oxygen end)