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

Why does this take 2 deaths to work?

Asked by 9 years ago
for _, player in pairs(game.Players:GetPlayers()) do
                coroutine.resume(coroutine.create(function()
                    player.CharacterAdded:connect(function(character)
                        character:WaitForChild("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

This works, it gives the team +1 point when then kill someone, but if you kill someone and they are the first to die then it doesnt do anything. You wait till you kill another person then the score starts working. How can I get so it doesnt do that

Answer this question