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

Help with finding "creator"?

Asked by 10 years ago
for _, player in pairs(game.Players:GetPlayers()) do
                coroutine.resume(coroutine.create(function()
                    player.CharacterAdded:connect(function(character)
                        character:WaitForChild("Humanoid")
                        print("4")
                        character.Humanoid.Died:wait()
                        print("4.5")
                        if character.Humanoid:FindFirstChild("creator") then
                            print("5")
                            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
                            print("6")
                            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

When a player dies and is added back to the workspace it prints 4 but it does print 5 after it trys to find creator. Please help. Im just want this script to check when a player dies and give the team who killed the player a point, like paintball or something i guess

EDIT I editted your answer, so I didnt get the error. You forgot to add.Humanoid after character on line 5. I added that but then it just printed 4 no error, just a bunch of 4's in the server output

0
I'm not sure what the problem is. You said 'it prints 4 but it does prints 5 after it tries to find creator.' Don't you mean it DOESN'T print 5? Redbullusa 1580 — 10y
0
yeah dosent, so its something on line 5 NinjoOnline 1146 — 10y
0
do you know how to check if someone died the give a team +1 score? NinjoOnline 1146 — 10y

1 answer

Log in to vote
1
Answered by
M39a9am3R 3210 Moderation Voter Community Moderator
10 years ago

Your script doesn't check for creator when the player dies, it checks for the creator value when they respawn. You would want to use the Humanoid Died Event for the script to look for creator when the player dies.

for _, player in pairs(game.Players:GetPlayers()) do
coroutine.resume(coroutine.create(function() --I just added this because I was concerned the script would pause until the first player died. The coroutine is kind of like a separate script.
    player.CharacterAdded:connect(function(character)
        character:WaitForChild("Humanoid")
    print("4")
        character.Died:wait() --A trick I learned, it will keep the event in wait until the player dies.
        if character.Humanoid:FindFirstChild("creator") then
            print("5")
            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
            print("6")
            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 of the coroutine.
end
0
EDIT: There is an error, check question for error NinjoOnline 1146 — 10y
0
Oh, sorry about that. I guess I was in a rush to answer I accidentally skipped to the .Died Event. M39a9am3R 3210 — 10y
0
ok, well I kinda changed it again, with full output, etc NinjoOnline 1146 — 10y
0
it still dosent work though NinjoOnline 1146 — 10y
Ad

Answer this question