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

Why does my gamepass button prompt when i purchased it already?

Asked by 5 years ago

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)
0
do you have the boombox on your inventory? Leamir 3138 — 5y
0
The boombox is in serverstorage and gets move to the backpack as I do not want it in starterpack. SilviaTheros911 0 — 5y
0
Congratulations, you trusted the client and you were robbed. User#21908 42 — 5y
1
a hacker can just do GiveBoomBox:FireServer() and get the boombox, add serverside check instead Warfaresh0t 414 — 5y
0
same issue as with your other thread, you don't actually get the gamepass when you buy it in studio, it just fires PromptGamePassPurchaseFinished User#22604 1 — 5y

1 answer

Log in to vote
-1
Answered by 5 years ago

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 :)

0
nope, you can User#22604 1 — 5y
Ad

Answer this question