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

Trying To Check If Player Has Gamepass?

Asked by 6 years ago

I am trying to check if the play has the gamepass then fire the event but it isn't working.

local id = 1570193898 -- ID of gamepass
local lazerAuth = false

game.Players.PlayerAdded:connect(function(player)
    if game:GetService("GamePassService"):PlayerHasPass(player, id) then 
        lazerAuth = true
    else
        print(player.Name .. " doesn't have the game pass...")
    end
end)



-- Fire The Event To Disable The Lazers

local clickdetector = game.Workspace.LazerDisable.DisableLazersButton.ClickDetector
clickdetector.MouseClick:Connect(function(plr)


if lazerAuth == true then

game.Workspace.LazerDisable.DisableLazerEvent:FireServer()

else

game:GetService("MarketplaceService"):PromptPurchase(plr, id)

local marketplaceService = game:GetService("MarketplaceService")

marketplaceService.PromptPurchaseFinished:connect(function(player,assetId,isPurchased)
    if isPurchased then --if the player did pay
        if assetId == id then --if what they bought is the pass
             game.Players.LocalPlayer:Kick("Please Rejoin The Game To Activate Your GamePass")
        end
    end
end)
end
end)
0
Explain the problem. cabbler 1942 — 6y

Answer this question