I need to make this somehow to work for just the people with the gamepass, its a team changer Script:
script.Parent.MouseButton1Click:Connect(function() workspace.TeamEvents.TeamEvent:FireServer(script.Parent.Text) end)
local remote = game.Workspace:WaitForChild("Folder").CheckGamepass script.Parent.MouseButton1Click:Connect(function() remote:FireServer() --fires a remote event here to see if the player has the gamepass workspace.TeamEvents.TeamEvent:FireServer(script.Parent.Text) end)
local MarketplaceService = game:GetService("MarketplaceService") local remote = game.Workspace:WaitForChild("Folder").CheckGamepass --check to see if the player has the team gamepass function checkForGamepass(player, gamepassID) local succ, hasGamepass = pcall(function() return MarketplaceService:UserOwnsGamePassAsync(player.UserId, gamepassID) end) if(succ)then if hasGamepass then print("player owns pass") return true else print("player does not have gamepass") end else print("was not successful ", succ) end return false end --this function gets ran when the CheckGamepass remote event gets fired remote.OnServerEvent:Connect(function(player) local hasTeamGamePass = checkForGamepass(player, 7673825) if hasTeamGamePass then player.Team = game.Teams["GamepassTeam"] end end)
UserOwnsGamePassAsync
, this will return whether the given player has a given gamepass.
local GamepassID = -- Your Gamepasses ID local PlayerID = game.players.localplayer script.Parent.MouseButton1Click:Connect(function() if game:GetService("MarketplaceService"):UserOwnsGamePassAsync(PlayerID, GamepassID) then workspace.TeamEvents.TeamEvent:FireServer(script.Parent.Text) end end)
Something like that,