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
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.
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.