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

When players buy my gamepasses nothing happens?

Asked by 6 years ago

Recently I got several people asking why their gamepasses weren't working in my game. At the time, I just assumed that the pass purchase hadn't gone through yet, so I simply told them to wait. But after a few days, none of them still had the passes. I checked the simple pass script I had and noticed the output throwing tons of warnings that consisted mainly of GamePassId [id here] is not of type Game Pass. Please use MarketplaceService:PlayerOwnsAsset instead.

So I tried using that instead, which was even worse and returned false every single time I used it.

I'm not sure how to fix this.

My extremely inefficient code is written below:

local Players = game:GetService("Players")
local repStorage = game:GetService("ReplicatedStorage")

function giveTool(tool, startGear)
    local newTool = tool:Clone()
    newTool.Parent = startGear
end

Players.PlayerAdded:Connect(function(plr)
    local starterGear = plr:WaitForChild("StarterGear")
    if game:GetService("GamePassService"):PlayerHasPass(plr, 4351689) then
        giveTool(repStorage:WaitForChild("ToolStorage"):WaitForChild("IT'S JUST AN EGG"), starterGear)
    end
    if game:GetService("GamePassService"):PlayerHasPass(plr, 4382733) then
        giveTool(repStorage:WaitForChild("ToolStorage"):WaitForChild("Protest Sign"), starterGear)
    end
    if game:GetService("GamePassService"):PlayerHasPass(plr, 4351698) then
        for i=1, 10 do
            local q = repStorage:WaitForChild("ToolStorage"):WaitForChild("Quarter"):Clone()
            q.Parent = starterGear
            game:GetService("Debris"):AddItem(q, 1)
        end
        for i=1, 75 do
            giveTool(repStorage:WaitForChild("ToolStorage"):WaitForChild("Quarter"), starterGear)
        end
        if game:GetService("GamePassService"):PlayerHasPass(plr, 4351704) then
            giveTool(repStorage:WaitForChild("ToolStorage"):WaitForChild("Lemonade Stand"), starterGear)
        end
    end
end)

It is a server script, is in ServerScriptService, and is not disabled.

3 answers

Log in to vote
0
Answered by
Fifkee 2017 Community Moderator Moderation Voter
6 years ago
Edited 6 years ago

Gamepasses take time to go through. If you buy a gamepass ingame (or buy a gamepass and immediately join a game) it usually doesn't work. Give it time. Plus, try reformatting your code. Always works for me.

0
I did all of the above. steven73598233 75 — 6y
Ad
Log in to vote
0
Answered by
hellmatic 1523 Moderation Voter
6 years ago

I think you can only check if they have the gamepass using a local script. Try converting it into a local script, and place it in StarterPlayerScripts under the StarterPlayer folder.

0
No need for PlayerAdded if you place it in StarterPlayerScripts hellmatic 1523 — 6y
0
I tried this, it didn't affect anything. Same results, same warnings. steven73598233 75 — 6y
Log in to vote
0
Answered by 6 years ago

The problem's fixed. Apparently, I have to use game:GetService("MarketplaceService"):UserOwnsGamePassAsync().

Answer this question