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

GamePassService.PlayerHasPass returns FALSE

I have a game that uses the game pass service to award extra tools.

It works pretty well.

Another ROBLOX employee bought my game pass this morning, entered the game, and did not get tools. Resetting the place fixed the problem.

Are there known limitations where this call will fail (i.e. return FALSE when the answer should be TRUE)?

3 comments

1

I'm pretty sure the request is cached, but from your question, I'm going to go ahead and assume that's not the issue here.

5

My question is exactly that - if this result is getting cached under any circumstances, it is a bug ROBLOX needs to fix.

1

I know it is cached, but it is on the game server. When the game server closes or the player joins another server, the call will work correctly. It will only be cached if it was called once before from the game server. It would be best for it to not be cached at all, so player's don't have to join another server if they buy a game pass in-game.

4 answers

✓ Accepted answer

There's this neat twitter post detailing the differences between UserHasBadge, PlayerHasPass and PlayerOwnsAsset.

From the looks of it, what you're probably doing is calling PlayerHasPass before awarding the player the game pass, and then calling it again later once they've received the game pass. Since it returned true after resetting the place, it's probably not in a LocalScript and most likely a caching problem.

If you are trying to give a sword, I would consider using this.

wait(2)

gpid = 155854150
tools = {"TOOLNAMEHERE"} -put the sword in Lighting

GPS = Game:GetService ("GamePassService")
function respawned (char)
player = game.Players:FindFirstChild(char.Name)
print("Respawned")
if char:FindFirstChild("Head") ~= nil then
print("It's a Player!")
if GPS:PlayerHasPass(player, gpid) then
print("Has GPID")
for i = 1,#tools do
game.Lighting:FindFirstChild(tools[i]):Clone().Parent = player.Backpack
end
else
print("No GPID")
end
end
end
game.Workspace.ChildAdded:connect(respawned)

By default, I use the game:GetService("BadgeService")UserHasBadge(ItemID). It is able to be used with any type of asset, Game Passes, Badges, Models, etc.

Are you sure your function for when a player enters is good? That the event is PlayerAdded, not ChildAdded ? They make a difference.

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