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

Game pass in-game purchase prompt is failing to come up?

Asked by 6 years ago
Edited 6 years ago

I have a script that gives a player a tool immediately after buying a game pass in-game.

Here is what I have

local Id = 793933317
local Gamepass = game:GetService("GamePassService")

script.Parent.ClickDetector.MouseClick:connect(function(plr)
    game:GetService("MarketplaceService"):PromptPurchase(plr, Id)
    if Gamepass:PlayerHasPass(plr, Id) then
        game.Lighting.Sabre:clone().Parent = plr.Backpack
        game.Lighting.Sabre:clone().Parent = plr.StarterGear
end
end)

It should work, however, I'm getting the error

"game passes can only be queried by a script running on a roblox game server"

Also, is this script looped? I.e will it give the player the tool again after dying?

Help would be much appreciated

0
I think you need to be in an actual roblox server, not in Play Solo. hiimgoodpack 2009 — 6y

2 answers

Log in to vote
1
Answered by
ali7682 17
6 years ago

I don't know much about scripting but i think you've made a little mistake by testing your gamepass out in roblox studio. You should test it out in a real roblox server. While doing that, test out if your script is looped by respawning. Hope this helped.

0
That happens to me sometimes too :P RicheeNektar 78 — 6y
Ad
Log in to vote
-1
Answered by 6 years ago

you should probably use 'PlayerOwnsAsset' instead of 'PlayerHasPass' and since the gear is being added to the player's starterpack, the tool will stay after dying.

Answer this question