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

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

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

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.

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

1 comment

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?

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