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

Why don't my gamepasses work until player quits & rejoins game?

Asked by 5 years ago

Hello! I have my gamepasses set up where a player clicks on a sign and purchases the gamepass. When they purchase the gamepass, the "gear" they purchased does not appear in their inventory until they leave & come back.

Any suggestions?

Both scripts are in Workplace.

local Id = 5555555 -- gamepass ID
local VipPlayers = {"test"} -- VIP Player
local ToolName = {"test"} -- Tools in ServerStorage

local function FindPlayer(Plr)
    for Num, Pler in pairs(VipPlayers) do
        if Pler == Plr then
            return true
        end
    end
end

game.Players.PlayerAdded:connect(function(Player)
    if game:GetService("MarketplaceService"):UserOwnsGamePassAsync()(Player.UserId, Id) or FindPlayer(Player.Name) then 
        Player.CharacterAdded:Connect(function(character)
            for Num, Tool in pairs(ToolName) do
                if game:GetService("ServerStorage"):FindFirstChild(Tool) then
                    game:GetService("ServerStorage")[Tool]:Clone().Parent = Player.Backpack
                end
            end
        end)

        for Num, Tool in pairs(ToolName) do
            if Player.Backpack:FindFirstChild(Tool) == nil then
                if game:GetService("ServerStorage"):FindFirstChild(Tool) then
                    game:GetService("ServerStorage")[Tool]:Clone().Parent = Player.Backpack
                end
            end
        end
    end
end)

This script is in the sign the user clicks on

local CLICK_BLOCK = script.Parent
local gamePassId = 5555555 

local Click = Instance.new("ClickDetector",CLICK_BLOCK)

Click.MouseClick:connect(function(UserID)
    game:GetService("MarketplaceService"):PromptGamePassPurchase(UserID, gamePassId)
end)

2 answers

Log in to vote
2
Answered by 5 years ago

Roblox saves the player's gamepasses when they join. When they check what gamepasses they have, they check the saved list. It's impossible (as far as I know) to re-check the gamepasses without the player rejoining.

Ad
Log in to vote
0
Answered by 5 years ago

AwesomeUniverseYT is right but you could try to give the person the gear after he bought it in his inventory and add the Gamepass so that he does not need to rejoin

0
I have tried tons of different things but can't seem to get that to work. Any suggestions on how to incorporate that in my script? bella_boopy 13 — 5y

Answer this question