Hi! So I made a gamepass that makes X2 coins but, I want to check if the player has the gamepass but I have to check that in another script here is the script (I used UserOwnsGamePassAsync but did not work)
local mps = game:GetService("MarketplaceService")
local button = script.Parent
local debounce = false
local gamePassID = 9189975
button.Touched:Connect(function(hit)
debounce = true
if hit.Parent:FindFirstChild("Humanoid") then
local player = game.Players:GetPlayerFromCharacter(hit.Parent)
if not player then return end
if player then
if player.Team.Name == "Red" then
if mps:UserOwnsGamePassAsync(player, gamePassID) then
player.leaderstats.Money.Value = player.leaderstats.Money.Value + button.Parent.Screen.MoneySaved.Value * 2
button.Parent.Screen.MoneySaved.Value = 0
debounce = false
if debounce == false then
button.BrickColor = BrickColor.new("Really red")
wait(2)
button.BrickColor = BrickColor.new("Sea green")
end
end
end
end
end
end)

1 comment
I suggest using user.Id instead of player because the player name can change but the userid can not.