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

How do i make something happen if a Player Dies?

Asked by 10 years ago

Im trying to make a script that sets a BoolValue to True but i dont know how to do that! Please Help!

game.Players.PlayerAdded:connect(function(player)
    local leaderstats = Instance.new("Model", player)
    leaderstats.Name = "leaderstats"
    local wins = Instance.new("IntValue", leaderstats)
    wins.Name = "Wins"
    wins.Value = 0
    local dead = Instance.new("BoolValue", player)
    dead.Name = "Died"
    dead.Value = false
end)


while wait(120) do 
    for _,Player in pairs(game.Players:GetPlayers()) do
        if Player.Died.Value == false then
            Player.leaderstats.Wins.Value = Player.leaderstats.Wins.Value +1

                    else

            game.Players.Player.Died.Value = false

        end
    end
end

local player = game.Players.LocalPlayer

game.Workspace.player.Humanoid.Changed:connect(function()
    if game.Workspace.player.Humanoid.Health == 0 then
        Player.Died.Value = true
    end
end)

0
Player.CharacterRemoving fires right after someone dies. GoldenPhysics 474 — 10y

2 answers

Log in to vote
0
Answered by
KAAK82 16
10 years ago

Died() is an event :P Check this

0
Yes, but thats of the humanoid. CharacterRemoving is more direct. GoldenPhysics 474 — 10y
0
GoldenP, but not everyone Deletes the Body... some people leave the Body as to scare people in Horror Games, like Darkness... Character = Model of Player... so if it's not Deleted then, the function isn't fired, cos the Body is still there, but yeah, it is if ur doing Default Death (Which I don't like, and don't recommend) KAAK82 16 — 10y
Ad
Log in to vote
0
Answered by 10 years ago
player = game.Players.LocalPlayer.Name

game.Workspace.player.Humanoid.Changed:connect(function()
    if game.Workspace.player.Humanoid.Health == 0 then
        boolvalue = true
    end
end)

Something like this I believe.

0
tkdrocks2017 i tried it in this but it wont work =( did i put it in wrong? game.Players.PlayerAdded:connect(function(player) local leaderstats = Instance.new("Model", player) leaderstats.Name = "leaderstats" local wins = Instance.new("IntValue", leaderstats) wins.Name = "Wins" wins.Value = 0 local dead = Instance.new("BoolValue", player) dead.Name = "Died" dead.Valu theamazemanII 32 — 10y

Answer this question