Problems with friend and creator only team

Ah, it’s me again! A builder who scripts!
(im still learning ok)

Okay so, I wanted to make a team for my friends and me only.
Can anyone explain why this code does not work?

local player = game.Players.LocalPlayer
local council = game.Teams.Councillor
local review = game.Teams.Reviewers
local creatorID = 112804226

if player.UserId == creatorID or player:IsFriendsWith(creatorID) then
	player.Team = council
else
	player.Team = review
end

If you have a solution, leave a reply if you think you can fix this code because as I mentioned. I am a builder who scripts. But I did make some working scripts like removing player collision.

You should set a player’s team on the server, not on the client.

Could you elaborate on that, please?

Then use Players.PlayerAdded event to check if its you or your friend who joined and set the team.
(sorry i cant code rn bcuz im on mobile)

This?

game.Players.PlayerAdded:Connect(function(player)
	if player.UserId == creatorID or player:IsFriendsWith(creatorID) then
		player.Team = council
	else
		player.Team = review
	end
end)

Yes that is what I’m talking about

1 Like

If you set a player’s team on the client, it won’t work because stuffs that is done on the client is not replicated to the server. So like @TheLegendaryDragon99 said, do a Players.PlayerAdded event in a normal script.

Yeah I already marked his comment on solution. But thanks for elaborating.

because it works now