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

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

Asked by 5 years ago

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

Log in to vote
0
Answered by 5 years ago
Edited 5 years ago

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)
0
Thanks a lot :) Superameno 34 — 5y
Ad

Answer this question