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

Gamepass purchase keeps failing to purchase in studio. What am I missing?

Every time I try to test a starter pack as a gamepass item in studio the prompt window comes down and says "purchase failed because something went wrong. Please try again later"

local MarketplaceService = game:GetService("MarketplaceService")
local Button = script.Parent
local id = (I have this I'm not sure if I should put it here)
local player = game.Players.LocalPlayer

Button.MouseButton1Click:Connect(function()
	MarketplaceService:PromptGamePassPurchase(player, id)
end)

I suppose there is a small chance it could be studio because it is saying to try again later, but I figure it's my code or something missing from it.

2 answers

Put an IntValue inside the badge part, with the badge id, and add this regular script to the part aswell:

function OnTouch(part)
	if (part.Parent:FindFirstChild("Humanoid") ~= nil) then
		local p = game.Players:GetPlayerFromCharacter(part.Parent)
		if (p ~= nil) then
			print("Awarding BadgeID: " ..script.Parent.BadgeID.Value .. " to UserID: " .. p.userId)
			local b = game:GetService("BadgeService")
			b:AwardBadge(p.userId, script.Parent.BadgeID.Value)
		end
	end
end

script.Parent.Touched:connect(OnTouch)

1 comment

0

Unrelated?

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