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

Why gamepass checker from serverscript doesnt work???

Hello, Why gamepass checker doesnt work(the script is from dev hub)

local MarketplaceService = game:GetService("MarketplaceService")

local gamePassID = 11925428
local gamePassName = "TripleHatch"

local TripleBtn = game.StarterGui.EggHatch.ChooseHatch.TripleBtn

local function onPromptGamePassPurchaseFinished(player, purchasedPassID, purchaseSuccess)
	
	if purchaseSuccess == true and purchasedPassID == gamePassID then
		print(player.Name .. "Owned the gamepass" .. gamePassName " -" .. gamePassID)
		TripleBtn.Owned.Disabled = false
		TripleBtn.NotOwned.Disabled = true
	end
end

-- Connect "PromptGamePassPurchaseFinished" events to the "onPromptGamePassPurchaseFinished()" function
MarketplaceService.PromptGamePassPurchaseFinished:Connect(onPromptGamePassPurchaseFinished)

1 answer

✓ Accepted answer

Well, in Line 6, you are indexing StarterGui instead of PlayerGui. If it's a Server Script, keep your variable inside your function.

local function onPromptGamePassPurchaseFinished(player, purchasedPassID, purchaseSuccess)

	local TripleBtn = player:WaitForChild("PlayerGui").EggHatch.ChooseHatch.TripleBtn

   	if purchaseSuccess and purchasedPassID == gamePassID then
        	print(player.Name .. "Owned the gamepass" .. gamePassName " -" .. gamePassID)
        	TripleBtn.Owned.Disabled = false
        	TripleBtn.NotOwned.Disabled = true
    	end
end

Lemme know if it helps!

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