So I have this team change script in my team change GUI. I want specific team change buttons to only work if you have the right gamepass. How would I go about doing that? current script:
local teamname = "(Captain)" local button = script.Parent local player = script.Parent.Parent.Parent.Parent.Parent local gui = script.Parent.Parent.Parent button.MouseButton1Click:connect(function() player.TeamColor = BrickColor.new "(Really black)" player.Character.Huminoid.Health = 0 gui.Enabled = false gui.ResetOnSpawn = false end)?
You can use the :PlayerOwnsAsset
function from MarketplaceService to check if the player owns the gamepass, like so:
local MarketplaceService = game:GetService("MarketplaceService") local button = script.Parent local player = button.Parent.Parent.Parent.Parent local id = gamepass_id_here button.MouseButton1Click:connect(function() if MarketplaceService:PlayerOwnsAsset(player, id) then player.TeamColor = BrickColor.new("Really black") player:LoadCharacter() end end)
It takes two arguments; the player and the asset's id to see if that player owns said asset.