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

How would I make this team change button script work for owners of a gamepass?

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)?

1 answer

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.

1 comment

0

I put this into my button, made sure the team color was the same and added the gamepass ID and it didnt work!

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