This is the team changer script I have for the GUI :
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.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) but i have this script in the work place
local player = game.Players.LocalPlayer
local gamepassId = 162872866
local hasGamepass = player:PlayerHasPass(gamepassId)
if hasGamepass then
player.Team = game.Teams.Imam
end
and it doesn’t wor. How do I make it so it checks if the player owns it?
like this? local Opened = false
local Teams = game:GetService(“Teams”)
local MarketplaceService = game:GetService(“MarketplaceService”)
local GamePassId = 162872866 – replace with your game pass ID
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 MarketplaceService:UserOwnsGamePassAsync(game.Players.LocalPlayer.UserId, GamePassId) then
script.Parent.Parent.Parent.Team = Teams.Imam
script.Parent.Parent.Parent.Team.TeamColor = Teams.Imam.TeamColor
wait()
script.Parent.Parent.Parent:LoadCharacter()
else
game:GetService(“MarketplaceService”):PromptGamePassPurchase(game.Players.LocalPlayer, GamePassId)
end
end)
script.Parent.Frame.Normal.MouseButton1Click:Connect(function()
if MarketplaceService:UserOwnsGamePassAsync(game.Players.LocalPlayer.UserId, GamePassId) then
script.Parent.Parent.Parent.Team = Teams.Normal
script.Parent.Parent.Parent.Team.TeamColor = Teams.Normal.TeamColor
wait()
script.Parent.Parent.Parent:LoadCharacter()
else
game:GetService(“MarketplaceService”):PromptGamePassPurchase(game.Players.LocalPlayer, GamePassId)
end
end)
Alright. Let me help. Let’s start with this snippet from the end of your code.
local MS = game:GetService("MarketplaceService")
local player = game.Players.LocalPlayer
local gamepassId = 162872866
local hasGamepass = MS:UserOwnsGamepassAsync(player.UserId, gamepassId)
if hasGamepass then
player.Team = game.Teams.Imam
end
Okay, ```local MS = game:GetService(“MarketplaceService”)
local player = game.Players.LocalPlayer
local gamepassId = 162872866
local hasGamepass = MS:UserOwnsGamepassAsync(player.UserId, gamepassId)
if hasGamepass then
player.Team = game.Teams.Imam
endThe game pass id is correct. But do I puit the code you gave at the bottom bellow: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)```
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()
script.Parent.Parent.Parent.Team = Teams.Imam
script.Parent.Parent.Parent.Team.TeamColor = Teams.Imam.TeamColor
wait()
script.Parent.Parent.Parent:LoadCharacter()
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)
local MS = game:GetService("MarketplaceService")
local player = game.Players.LocalPlayer
local gamepassId = 162872866
local hasGamepass = MS:UserOwnsGamepassAsync(player.UserId, gamepassId)
if hasGamepass 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()
script.Parent.Parent.Parent.Team = Teams.Imam
script.Parent.Parent.Parent.Team.TeamColor = Teams.Imam.TeamColor
wait()
script.Parent.Parent.Parent:LoadCharacter()
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)
local MS = game:GetService("MarketplaceService")
local player = game.Players.LocalPlayer
local gamepassId = 162872866
local hasGamepass = MS:UserOwnsGamepassAsync(player.UserId, gamepassId)
if hasGamepass 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()
script.Parent.Parent.Parent.Team = Teams.Imam
script.Parent.Parent.Parent.Team.TeamColor = Teams.Imam.TeamColor
wait()
script.Parent.Parent.Parent:LoadCharacter()
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)
local MS = game:GetService("MarketplaceService")
local player = game.Players.LocalPlayer
local gamepassId = 162872866
local hasGamepass = MS:UserOwnsGamepassAsync(player.UserId, gamepassId)
if hasGamepass then
player.Team = game.Teams.Imam
end```
Your error is that you haven’t used pcall here and it will only be in client here is fixed one and use basic script:
local MarketplaceService = game:GetService("MarketplaceService")
local GamePassId = 162872866
game.Players.PlayerAdded:Connect(function(Player)
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
end)