Attempt to Index Number with ProductId

  1. What do you want to achieve? I want to create a revive system that removes a game over GUI and teleports the player to spawn when purchased with robux.

  2. What is the issue? I get an error saying this:

  3. What solutions have you tried so far? I have looked on the developer hub to no avail. I have tried putting the product ID into a table and quotations. I am unsure how I am supposed to reference the developer product ID without a number.

Below is the script:

local player = game.Players.LocalPlayer
local playerUI = player.PlayerGui
local HRP = player.Character:WaitForChild("HumanoidRootPart")
local spawnPoint = game.Workspace.SpawnLocation

local textButton = script.Parent
local PRODUCT_ID = 1739810149

local function onButtonClick()
	game:GetService("MarketplaceService"):PromptProductPurchase(game.Players.LocalPlayer, PRODUCT_ID)
end

textButton.MouseButton1Click:Connect(onButtonClick)

local function onProductPurchase(purchaseInfo)
	if purchaseInfo.ProductId == PRODUCT_ID then
		playerUI.GameOverGUI.Enabled = false
		HRP.CFrame = spawnPoint.CFrame + Vector3.new(0, 4, 0)
	end
end

game:GetService("MarketplaceService").PromptProductPurchaseFinished:Connect(onProductPurchase)
1 Like

PromptProductPurchaseFinished gives you 3 parameters to work with, the UserId of the player that purchased the product, the productId, and a boolean if the product was purchased or not.

Given how you’re using the event, you should really be using ProcessReceipt instead as it’s the ideal way to process if a product had been purchased or not

3 Likes

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.