(PlayerDyingEvent)
local alive = 0
for _, player in PlayerService:GetPlayers() do
if not player.Character then continue end
if not player.Character: FindFirstChild("Humanoid") then continue end
if player.Character.Humanoid.Health <= 0 then continue end
alive += 1
end
if alive == 0 then
sound:Play()
end
end
#how make script if all players are dead - play a sound
27 messages · Page 1 of 1 (latest)
how it's gonna work?
Here ya go
Basically when a player dies, you check for all player's character in the game
If there is none, you can just play the sound
yea that code should work
but you didnt tell him to actually make that player death event
I edited it so it checks for humanoid health now
local PlayerService = game:GetService("Players")
local alive = 0
local sound = game.Workspace.Sound
for _, player in PlayerService:GetPlayers() do
if not player.Character then continue end
alive += 1
end
if alive == 0 then
sound:Play()
end
bo.
n.o
no.
so
first of all
you need to detect when a player dies
for that, i suggest connecting humanoid.Died in player.added and character.added
after that call the function that he made
Haha ure right
local sound= game workspace.sound local players = game.Players if players.Localplayer.Character.Humanoid.Health == 0 then sound:Play()?