So i want my character play my "custom" sound when he dies and he can only hear it.
script that clones this in him
local Wasted = script.Wasted:Clone() game.Players.PlayerAdded:connect(function(player) player.CharacterAdded:wait() Wasted:Clone().Parent = player end)
script that should play when he dies ONLY FOR HIM...
Player = script.Parent.Parent.Parent.Parent.Character Wasted = script.Parent s = Player.Humanoid while true do if s.Health <= 0 then Wasted:Play() end end
http://prntscr.com/8aqhj0 <<<< how my setup looks. is this right or is something wrong ? No errors in output tho... :/
I would recommend that you use a localscript for this and parent it into the starterpack and then put the Wasted audio inside the localscript. There is a custom event for humanoids that fire when they die, it's called Died
, this is much more efficient to use than a while loop, and by the looks of the one you have in your script, your game should be crashing since there is no wait() inside of the loop.
--LOCALSCRIPT put wasted audio inside this and put this script into starterpack-- local runservice = game:GetService'RunService' local wasted = script:WaitForChild'Wasted' repeat runservice.RenderStepped:wait() until game.Players.LocalPlayer and game.Players.LocalPlayer.Character local player = game.Players.LocalPlayer local character = player.Character local humanoid = character:WaitForChild'Humanoid' humanoid.Died:connect(function() wasted:Play() end)