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!
COMMUNITY QUESTION
I nead a GUI for my game that will change your team ONLY if you have a gamepass, can someone help?
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
This discussion is preserved as it was. New answers, comments, and votes are closed.

5 comments
I will try this thank you
Ok, Im sorry if im asking for too much but How can I make it when the GUI button is clicked?
We aren't Google. Search it up.
I tried
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