Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

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

Asked by 7 years ago

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

Log in to vote
0
Answered by
caoshen 96
7 years ago

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.

0
I put this into my button, made sure the team color was the same and added the gamepass ID and it didnt work! Hellst0rm -3 — 7y
Ad

Answer this question