Script team change GUI

local MarketplaceService = game:GetService("MarketplaceService")

local Player = game:GetService("Players").LocalPlayer
local GamePassId = 162872866
local HasPass = false
local success, message = pcall(function()
		HasPass = MarketplaceService:UserOwnsGamePassAsync(Player.UserId,GamePassId)
		print(HasPass)
	end)
	if HasPass == true then
        Player.Team = game.Teams.Imam
	end
local Opened = false
local Teams = game:GetService("Teams")

script.Parent.Team.MouseButton1Click:Connect(function()
if Opened == false then
script.Parent.Frame:TweenPosition(UDim2.new(0.236, 0,0.266, 0))
Opened = true
else
script.Parent.Frame:TweenPosition(UDim2.new(0.236, 0,-0.9, 0))
Opened = false
end
end)

script.Parent.Frame.Imam.MouseButton1Click:Connect(function()
if HasPass == true then
script.Parent.Parent.Parent.Team = Teams.Imam
script.Parent.Parent.Parent.Team.TeamColor = Teams.Imam.TeamColor
wait()
script.Parent.Parent.Parent:LoadCharacter()
end
end)

script.Parent.Frame.Normal.MouseButton1Click:Connect(function()
script.Parent.Parent.Parent.Team = Teams.Normal
script.Parent.Parent.Parent.Team.TeamColor = Teams.Normal.TeamColor
wait()
script.Parent.Parent.Parent:LoadCharacter()
end)```

--Idk why this isn't working. You can join me to test it. Also here is the model: 13129228399

I’m not quite sure what to do with this code. Can you tell me what’s the problem?

It changes the player team once the buy a game pass. But the problem is it does not work. There is a model id in there too.

@Xacima can u help please … I am confused

Model ID? It’s supposed to be a Gamepass ID, not a Model ID.

So if they buy a gamepads, their team gets changed, and if they rejoin WITH the gamepads, they get auto changed. Right?

No, if you buy the game pass and you can pick your team once you join

If you own the team you get if you don’t it promos purchase

pal this is all clientsided u need to make it serversided