Trouble With Died Screen With buyable respawn

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?

1 Like

If you have an answer please respond. His game is coming out tomorrow

There’s no way for anyone to help you if you just dump your script with no mention of an error or description of unintended behavior. Please highlight the part of the code that doesn’t work and elaborate further.

1 Like

Sorry, Forgot to do that.
This part is where it errors
game.Players.PlayerAdded:Connect(function(player)

player:LoadCharacter()

loadDiedFunction(player)

inside of the “normal script in server script service”
sorry for the lack of elaboration, I got no sleep last night.

Once you buy the revive, it does not reload your character. That’s my problem here

Could you try putting your script into code form like this:

game.Players.PlayerAdded:Connect(function(player)

player:LoadCharacter()

loadDiedFunction(player)

Never mind, Just figured out I had a typo in one of the scripts.