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

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

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)

5 comments

0

do you have the boombox on your inventory?

0

The boombox is in serverstorage and gets move to the backpack as I do not want it in starterpack.

0

Congratulations, you trusted the client and you were robbed.

1

a hacker can just do GiveBoomBox:FireServer() and get the boombox, add serverside check instead

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

1 answer

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

1 comment

0

nope, you can

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