Game pass tool script broke for some reason

Before… you would get the tool right away after you purchase the game pass.
Now you have to rejoin the game to get the tool… so what went wrong?
here is the script

local mps = game:GetService("MarketplaceService")
local gamepass_id = 0

game.Players.PlayerAdded:Connect(function(player)
    if mps:UserOwnsGamePassAsync(player.UserId, gamepass_id) then
        game.ServerStorage.DG:Clone().Parent = player:WaitForChild("Backpack")
        game.ServerStorage.DG:Clone().Parent = player:WaitForChild("StarterGear")
    end
end)


game.ReplicatedStorage.G4.OnServerEvent:connect(function(player)
    game.ServerStorage.DG:Clone().Parent = player:WaitForChild("Backpack")
    game.ServerStorage.DG:Clone().Parent = player:WaitForChild("StarterGear")
end)

This is because UserOwnsGamePassAsync caches, meaning that it will save the first result of checking if the user has a gamepass, even if it may not be true. On August 2018, this behavior was implemented.

1 Like

Weird
but it used to work just like i wanted to just till now.

It’s not documented, but the cache changes based on the result actually. If UserOwnsGamePassAsync returns true, that result will be cached for the rest of the game session. If it returns false, the value will only be cached for 10 seconds.

1 Like