--Heres What My Script Is Basically About.
--So basically when someone health is 0 or when they die the sound is suppose to play -- but it doesn't for some reason. It works in studio not in game
P = script.Parent.Parent.Parent.Parent.Character.Humanoid while true do wait(0.1) if P.Health == 0 then script.Parent.Script.Static:play() wait(100) end wait() end
Not sure what is wrong.
Instead of using a while loop, use the Died
event of humanoids.
As the event name implies, the code under the event will run when a humanoid dies.
Also, as Elite said, use :Play()
with an uppercase P, not a lowercase p. Coding is case sensitive.
-- You used too many .Parent's so I shortened it out. Use a player added event so when the player and character load, we can get the character, its Humanoid, and play the sound. game:GetService("Players").PlayerAdded:Connect(function(plr) plr.CharacterAdded:Connect(function(char) char.Humanoid.Died:Connect(function() script.Static:Play() end) end) end)
Your "play()" is lowercase, and this may cause an issue. You also can just use "script.Static" instead of "script.Parent.Script.Static" Try this:
P = script.Parent.Parent.Parent.Parent.Character.Humanoid while true do wait() if P.Health == 0 then script.Static:Play() wait(100) end end