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

I made a gamepass script in Roblox but it's not working?

Asked by 5 years ago

So basically this is my script `` -- This code should be within a 'LocalScript' object local MarketplaceService = game:GetService("MarketplaceService") local Players = game:GetService("Players")

local gamePassID = 6738501 -- Change this to your game pass ID

-- Function to prompt purchase of the game pass local function promptPurchase()

local player = Players.LocalPlayer
local hasPass = false

local success, message = pcall(function()
    hasPass = MarketplaceService:UserOwnsGamePassAsync(player.UserId, gamePassID)
end)

if not success then
    warn("Error while checking if player has pass: " .. tostring(message))
    return
end

if hasPass == true then
    -- Player already owns the game pass; tell them somehow
else
    -- Player does NOT own the game pass; prompt them to purchase
    MarketplaceService:PromptGamePassPurchase(player, gamePassID)
end

-- This code should be within a 'LocalScript' object local MarketplaceService = game:GetService("MarketplaceService") local Players = game:GetService("Players") local gamePassID = 6738501 -- Change this to your game pass ID -- Function to prompt purchase of the game pass local function promptPurchase() local player = Players.LocalPlayer local hasPass = false local success, message = pcall(function() hasPass = MarketplaceService:UserOwnsGamePassAsync(player.UserId, gamePassID) end) if not success then warn("Error while checking if player has pass: " .. tostring(message)) return end if hasPass == true then -- Player already owns the game pass; tell them somehow else -- Player does NOT own the game pass; prompt them to purchase MarketplaceService:PromptGamePassPurchase(player, gamePassID) end

So can u help me

0
in fact, you did not make this. Elixcore 1337 — 5y
0
It doesn't matter did he make it himself or did he take it we are here to help him. MiguRB 60 — 5y

1 answer

Log in to vote
0
Answered by 5 years ago

Try looking at the robloxdev.com/ article for GamePassService:PlayerHasPass(). I have a strong feeling I've encountered a problem like this before, and I believe this was how I worked it out. Sorry I couldn't give a straight answer, I couldn't wrap my head around your code, but I know marketplaceservice and gamepassservice do the same thing. :)

https://developer.roblox.com/en-us/api-reference/function/GamePassService/PlayerHasPass

Ad

Answer this question