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

Trying to make this PlayerAdded team script work, but it doesn't. No errors either?

I am trying to make it so that when a player joins, it checks if they are in a group, if they are they get put on the White team color team and if they aren't in the group, they get put on the Rust team color team.

This is my script that is in StarterPlayerScripts

game.Players.PlayerAdded:connect(function(p)
	if p:IsInGroup(3330867) then
		p.TeamColor = BrickColor.new("White")
	else p.Teamcolor = BrickColor.new("Rust")
	end
end)

1 answer

###You should not handle PlayerAdded on the client. This can be dangerous as you're giving the client power and access to the other player's properties. Put this code in ServerScriptService as a server script:

game:GetService("Players").PlayerAdded:Connect(function(p) -- switch to :Connect, :connect is deprecated
    if p:IsInGroup(3330867) then
        p.TeamColor = BrickColor.new("White")
    else 
        p.Teamcolor = BrickColor.new("Rust")
    end
end)

1 comment

0

Thanks a lot :)

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