Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

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

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

1 comment

0

I think you need to be in an actual roblox server, not in Play Solo.

2 answers

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.

1 comment

0

That happens to me sometimes too :P

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.

This discussion is preserved as it was. New answers, comments, and votes are closed.