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

Help with recording someone if they have died?

Asked by 9 years ago

I have this game, and if the gamemode is deathmatch then it checks when a player has died and gives the team a point, but it dosent work. It stops at that playeradded part. Please help

while wait() do
    if repstorage.RoundTag.Value == true then
        if repstorage.GameRound.Value == "Deathmatch" then
            game.Players.PlayerAdded:connect(function(player)
                player.CharacterAdded:connect(function(character)
                    character:WaitForChild("Humanoid")
                    character.Humanoid.Died:connect(function()
                        if character.Humanoid:FindFirstChild("creator") then
                            local tag = character.Humanoid.creator
                            local tColor = player.TeamColor
                            local kColor = tag.Value.TeamColor
                            if not kColor then return end
                            if not tColor then return end
                            if tColor ~= kColor then
                                if kColor == BrickColor.new("Lime green") then
                                    greenscore.Value = greenscore.Value + 1
                                elseif kColor == BrickColor.new("New Yeller") then
                                    yellowscore.Value = yellowscore.Value + 1
                                end
                            end
                        end
                    end)
                end)
            end)
        end
    end
end
0
output? Tesouro 407 — 9y
0
nothing, the output has no errors NinjoOnline 1146 — 9y

1 answer

Log in to vote
1
Answered by 9 years ago

Double check this, as it's been ages since I've done anything since I've worked with events such as PlayerAdded.

However, you're trying to update a scoreboard. The function, as it's being declared inside of the PlayerAdded event, will NOT run until a NEW player joins the game. So the code used to add the point cannot run, as it is withheld inside of the event handler.

Ad

Answer this question