I have a script that kills you and plays audio when you hit it. When the character respawns (AKA when the character is removed and placed at the spawn) it would stop the audio and become invisible. The problem here is that while it works perfectly in studio, the audio doesn't stop in play mode.
script.Parent.Touched:connect(function(p) if p.Parent:FindFirstChild("Humanoid") ~= nil then local char = p.Parent local plr = game.Players:GetPlayerFromCharacter(char) if char.Humanoid.Health > 0 then script.Parent.Decal.Texture = "insert texture here" script.Parent.Transparency = 0 local s = Instance.new("Sound") s.SoundId = "insert sound here" s.Volume = 1 s.Parent = plr.Backpack s:Play() script.LocalScript:Clone().Parent = plr.Backpack char.Humanoid.Health = 0 plr.CharacterRemoving:connect(function() script.Parent.Decal.Texture = "" --works script.Parent.Transparency = 1 --works s:Stop() --doesn't work, it keeps playing after the player respawns end) end end end)
Any ideas?