Team gamepass GUI

Greetings developers! Me and my friend are working on a project and he wants to have a gamepass team. I said okay and I made the team, made the team spawn, made the team select GUI and then the scripting part hit me. So I need help. My friend wants it so if the user clicks on the team and doesn’t have the gamepass, the user will get a prompt to purchase the gamepass. If the user DOES have the gamepass the prompt doesn’t show up and they automatically join the team. If you have any ideas or help please let me know. Thank you!

^Current team select script

You would add a check to see if the player owns the gamepass or not.

local player = script.Parent.Parent.Parent.Parent.Parent

   if --player owns gamepass (can't give you all the answers :) then
        player.Team = game.Teams:FindFirstChild("[RRT] Rapid Response Team")
        --prompt purchase 
1 Like

you should have just paste your code inside three back ticks instead of an photo

You’re gonna need a few resources for this. First, you’ll want to use PromptGamePassPurchase from the MarketplaceService. Then, because UI is client-side, you’ll need to use a remote to send a request to join the team server-side. The server will then need to check if they own the gamepass with PlayerOwnsAsset. If they do, change their team. If not, prompt the purchase with the reference I gave earlier.

Firstly, you should just handle UI’s on the client, since that’s what they are meant to be handled on. You will need to use UserOwnsGamePassAsync to check if a player owns a game pass.

You will need to hook up a remote event so you can check on the server if they own the pass, then change their team accordingly.

Client Code

local Players = game:GetService("Players") -- Gets the service for players
local ReplicatedStorage = game:GetService("ReplicatedStorage")

local Player = Players.LocalPlayer
local Button = -- Define button from gui

local Remote = ReplicatedStorage:FindFirstChild("RemoteEvent")

    -- I would switch to Activated but it's preference
    -- Fire remote to change their team

Server Code

local Players = game:GetService("Players") -- Gets the service for players
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local MarketplaceService = game:GetService("MarketplaceService")

local Remote = ReplicatedStorage:FindFirstChild("RemoteEvent")

local GamePassID = 0000 -- Edit to your needs

Remote.OnServerEvent:Connect(function(Player) -- First argument of server events are the player
	local OwnsPass = MarketplaceService:UserOwnsGamePassAsync(Player.UserId,GamePassID) 
    -- Will return True or False, use this info for team changing
	if OwnsPass then -- They own it
		-- Change team

Isn’t player PlayerOwnsAsset deprecated? I’ve been told to use MarketplaceService:UserOwnsGamePassAsync

@MightyDantheman @eizaray1234

PlayerOwnsAsset is used to check if a player owns an asset from the library or catalog. I don’t think it’s depreciated as there would be a tag on the wiki. PlayerOwnsGamePassAsync will check for Game passes only.

1 Like

I believe PlayerOwnsAsset works on gamepasses too, does it not?

Image from Gyazo

Straight from the wiki.

Ah, alrighty. The more you know. I prefer DevProducts anyway.