Hello, Basically I have made a gamepass button within the gui and i test in server and when I press the button, it prompts and I purchase it, the problem is if I press it again it prompts again and doesnt give me my item . I have already check that it is the right gamepass id and have check if everything works fine. I believe it has to do with caching because a few minutes later it works. So is there a faster way to cache gamepass prompt and check if i have it?
Localscript in button:
local GiveBoomBox = game:GetService("ReplicatedStorage").Events:WaitForChild("BoomBox") BoomBox = game.Players.LocalPlayer.Backpack:FindFirstChild("BoomBox") function click() print(BoomBox) if BoomBox == game.Players.LocalPlayer.Backpack:FindFirstChild("BoomBox") and game:GetService("MarketplaceService"):UserOwnsGamePassAsync(script.Parent.Parent.Parent.Parent.UserId, 5143841) then print("Boombox was nil") GiveBoomBox:FireServer() print(BoomBox) print("Boombox fired") elseif BoomBox ~= game.Players.LocalPlayer.Backpack:FindFirstChild("BoomBox") and game:GetService("MarketplaceService"):UserOwnsGamePassAsync(script.Parent.Parent.Parent.Parent.UserId, 5143841) then print("Already Have it") else game:GetService("MarketplaceService"):PromptGamePassPurchase(game.Players.LocalPlayer, 5143841) end end script.Parent.MouseButton1Down:connect(click)
Script in ServerScriptService:
game.ReplicatedStorage.Events.BoomBox.OnServerEvent:Connect(function(player) local Boombox = game.ServerStorage:FindFirstChild("BoomBox") Boombox:Clone().Parent = player.Backpack end)
As far as I'm aware you can't check if a player has an item in a local script, so you might have to use remote events to check if they have the gamepass. I might be wrong though as my knowledge of gamepasses is limited. Hope I've helped :)