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 Developer Product script not work?

On ROBLOX Tower I tried to have a developer product teleport the player instantly to their suite, the problem is it doesn't teleport them. I copied the code from PvP Battle which does work.

Here is the code:

local MarketplaceService = game:GetService("MarketplaceService")
--local ds = game:GetService("DataStoreService"):GetDataStore("PvPPurchaseHistory")
 
MarketplaceService.ProcessReceipt = function(receiptInfo) 
    -- find the player based on the PlayerId in receiptInfo
    for i, player in pairs(game.Players:GetPlayers()) do
        if player.userId == receiptInfo.PlayerId then
			--while player:FindFirstChild("leaderstats") == nil do wait() end
            -- check which product was purchased (required, otherwise you'll award the wrong items if you're using more than one developer product)
--            if(tonumber(receiptInfo.ProductId) == 19185476)then
--				player.leaderstats.Money.Value = player.leaderstats.Money.Value + 100
--			end
--			if(tonumber(receiptInfo.ProductId) == 19185483)then
--				player.leaderstats.Money.Value = player.leaderstats.Money.Value + 1000
--			end
--			if(tonumber(receiptInfo.ProductId) == 19185503)then
--				player.leaderstats.Money.Value = player.leaderstats.Money.Value + 10000
--			end
			if(tonumber(receiptInfo.ProductId) == 19620695)then
				pcall(function ()
					game:GetService("TeleportService"):Teleport(suiteIds:GetAsync(tostring(p.userId)),p)
				end)			
			end
		end
    end
    -- record the transaction in a Data Store
    --local playerProductKey = "player_" .. receiptInfo.PlayerId .. "_purchase_" .. receiptInfo.PurchaseId
   	--ds:IncrementAsync(playerProductKey, 1)	
    -- tell ROBLOX that we have successfully handled the transaction (required)
    return Enum.ProductPurchaseDecision.PurchaseGranted		
end

3 comments

0

Perhaps post the line of teleportation entirely?

0

game:GetService("TeleportService"):Teleport(suiteIds:GetAsync(tostring(p.userId)),p) There you go

0

If each index of receiptInfo is a string then receiptInfo.PlayerId will never be equal to player.userId. The wiki doesn't have an explanation of it yet so I'm not sure.

1 answer

I found out why... The suiteIds variable doesn't exist. Then fixed the variable pnot existing by changing it to player. I'm so happy for the in-game developer console.

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