Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

Help with death script?

Asked by
Zerio920 285 Moderation Voter
10 years ago

This is in a server script:

game.Players.PlayerAdded:connect(function(player)
repeat wait() until player:FindFirstChild("leaderstats")
local lives = player.leaderstats.Respawns
player.CharacterAdded:connect(function(char)
char:FindFirstChild("Humanoid").Died:connect(function()
wait()
lives.Value = lives.Value - 1
player:FindFirstChild("Backpack").Death:Play()
children = player.Backpack:GetChildren()
for _,v in pairs(children) do
if v:IsA("Sound") then
v:Stop()
v:Destroy()
wait()
end
end
end)
end)
end)

What I'm attempting to do here is two things: Remove one life from the player when he dies, as well as play a "death" sound. The problem is that this rarely works online for some reason. I tried a local script too but it doesn't seem to work. It could be a problem with the script or there might be some other way to do this that I'm not aware of. Any ideas?

0
Could you tab it please? acecateer 130 — 10y
0
tab? Zerio920 285 — 10y
0
Meaning indent. GoldenPhysics 474 — 10y
0
ok im making another question Zerio920 285 — 10y

Answer this question