Im trying to make a died GUI with a buyable respawn for my friends game but the purchase does not work
Local script in starter charatcter scripts
local TweenService = game:GetService(“TweenService”)
local MarketplaceService = game:GetService(“MarketplaceService”)
local TeleportService = game:GetService(“TeleportService”)
local player = game.Players.LocalPlayer
local diedEvent = game.ReplicatedStorage.DiedEvent
local reviveEvent = game.ReplicatedStorage.reviveEvent
local boughtLifeEvent = game.ReplicatedStorage.boughtLifeEvent
–
local ScreenGui = player.PlayerGui.ScreenGui
local extra_life = false
local function teleportToLobby()
TeleportService:Teleport(7183772458)
end
local function startTimer()
local timer = 15
repeat
timer = timer - 1
ScreenGui.Died.timer.Text = timer
wait(1)
until timer <= 0 or extra_life == true
if extra_life == true then
reviveEvent:FireServer()
ScreenGui.Died.Visible = false
else
teleportToLobby()
end
end
boughtLifeEvent.OnClientEvent:Connect(function()
extra_life = true
end)
ScreenGui.Died.continue.MouseButton1Down:connect(function()
MarketplaceService:PromptProductPurchase(player, 1199578085)
end)
ScreenGui.Died.btl.MouseButton1Down:connect(function()
teleportToLobby()
end)
diedEvent.OnClientEvent:Connect(function()
ScreenGui.Died.Visible = true
startTimer()
end)
normal script in Serverscriptservice
local MarketplaceService = game:GetService(“MarketplaceService”)
local diedEvent = game.ReplicatedStorage.DiedEvent
local reviveEvent = game.ReplicatedStorage.reviveEvent
game.Players.CharacterAutoLoads = false
function loadDiedFunction(player)
player.Character.Humanoid.Died:connect(function()
wait(1)
diedEvent:FireClient(player)
end)
end
game.Players.PlayerAdded:Connect(function(player)
player:LoadCharacter()
loadDiedFunction(player)
end)
reviveEvent.OnServerEvent:Connect(function(player)
player:LoadCharacter()
loadDiedFunction(player)
end)
2nd normal script in serverscriptservice
local MarketplaceService = game:GetService(“MarketplaceService”)
local boughtLifeEvent = game.ReplicatedStorage.Remotes.boughtLifeEvent
local function processReceipt(receiptInfo)
local player = game:GetService("Players"):GetPlayerByUserId(receiptInfo.PlayerId)
if player then
print(player.Name .. " just bought " .. receiptInfo.ProductId)
boughtLifeEvent:FireClient(player)
return Enum.ProductPurchaseDecision.PurchaseGranted
end
end
MarketplaceService.ProcessReceipt = processReceipt
remotes:
diedEvent
reviveEvent
boughtLifeEvent
the code fails to reload the character after the revive was bought,
Is there any way to fix this?