Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

I nead a GUI for my game that will change your team ONLY if you have a gamepass, can someone help?

I have a team change GUI in my game and I want a TextButton that will change your team when clicked if you have a gamepass, (Like if you have a prison game, Prisoners and Guards are free but Swat neads a gamepass to change your team to Swat) Can somebody help me? I tried everything I Know!

1 answer

You can use MarketplaceService’s UserOwnsGamePassAsync function to verify whether the given user has a Gamepass. This function returns a Boolean Value, meaning we can directly call it within a Conditional.

local MarketplaceService = game:GetService("MarketplaceService")
local GamepassId = --// Asset ID 

local Player = game:GetService("Players").LocalPlayer

local Button = script.Parent --// Place the Script within the TextButton

Button.MouseButton1Click:Connect(function()
    if (MarketplaceService:UserOwnsGamePassAsync(Player.UserId, GamepassId)) then
        --// Change team
    end
end

5 comments

0

I will try this thank you

0

Ok, Im sorry if im asking for too much but How can I make it when the GUI button is clicked?

0

We aren't Google. Search it up.

0

I tried

0

I’m afraid you didn’t try as hard as you could. You’ll find that it is truly easy to get the resources you need, especially if you just look through the Developer Forum. Please try a smidge harder next time, however, I will still assist you

This discussion is preserved as it was. New answers, comments, and votes are closed.