Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

Help with finding "creator"?

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

3 comments

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?

0

yeah dosent, so its something on line 5

0

do you know how to check if someone died the give a team +1 score?

1 answer

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

4 comments

0

EDIT: There is an error, check question for error

0

Oh, sorry about that. I guess I was in a rush to answer I accidentally skipped to the .Died Event.

0

ok, well I kinda changed it again, with full output, etc

0

it still dosent work though

This discussion is preserved as it was. New answers, comments, and votes are closed.