-
Trying to make pay to respawn GUI system with saves player tools. (DevProduct)
-
DevProduct works only in Studio, not working in team test or real game.
-
I was looking for similar topics but didn’t find anything helpful
Output prints only “2 complete” and then stops, why ProcessRecipt not working? (only Team Test, in Studio everything works well). You can see below ↓
Item saving after death script + checking if player bought devProduct ↓
local Players = game:GetService("Players")
local Market = game:GetService("MarketplaceService")
function OnPlayerAdded(Player)
print("OnPlayerAdded (1) - complete")
local SavedTools = {}
local function OnCharacterAdded(Character)
print("OnCharacterAdded (2) - complete")
Market.ProcessReceipt = function(recieptInfo)
print("Market (3) - complete")
if recieptInfo.ProductId == 1842353716 then
print("if ProductId (4) - complete")
local player = game.Players:GetPlayerByUserId(recieptInfo.PlayerId)
print(player)
player:LoadCharacter()
for Index, Tool in pairs(SavedTools) do --Loads all the saved tools from the player's last death
Tool.Parent = Player.Backpack
end
return Enum.ProductPurchaseDecision.PurchaseGranted
end
end
SavedTools = {}
local function OnDied() --Copies all your tools when you die and saves them to a table attached to the player
print('onDied 1')
for Index, Tool in pairs(Player.Backpack:GetChildren()) do
local CopiedTool = Tool:Clone()
table.insert(SavedTools, CopiedTool)
end
for Index, Tool in pairs(Player.Character:GetChildren()) do --Checks if theres a tool being currently used/equipped by the player
if Tool:IsA("Tool") then
local CopiedTool = Tool:Clone()
table.insert(SavedTools, CopiedTool)
end
end
end
Character.Humanoid.Died:Connect(OnDied)
end
Player.CharacterAdded:Connect(OnCharacterAdded)
end
for Index, Player in pairs(Players:GetChildren()) do --Redundency incase a player has joined before the event sets up
OnPlayerAdded(Player)
end
Players.PlayerAdded:Connect(OnPlayerAdded)
Dev Product button: ↓
local Market = game:GetService("MarketplaceService")
local id = 1842353716
local player = game.Players.LocalPlayer
script.Parent.MouseButton1Click:Connect(function()
Market:PromptProductPurchase(player, id)
end)
Any ideas whats wrong?