Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

Why does my Developer Product script not work?

Asked by
Gamenew09 180
10 years ago

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
0
Perhaps post the line of teleportation entirely? Bebee2 195 — 10y
0
game:GetService("TeleportService"):Teleport(suiteIds:GetAsync(tostring(p.userId)),p) There you go Gamenew09 180 — 10y
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. 1waffle1 2908 — 10y

1 answer

Log in to vote
0
Answered by
Gamenew09 180
10 years ago

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.

Ad

Answer this question