I’m trying to make a script that allows players to pay if they want to revive, however I’m having some problems.
When the player dies and pays to revive, they arent revived and just stay died. How would i be able to make them respawn
local player = plr.LocalPlayer
local character = player.Character
local humanoid = character:WaitForChild("Humanoid")
local function unlockMouse()
local mouseUnlocker = Instance.new("TextButton")
mouseUnlocker.Parent = script.Parent
mouseUnlocker.Modal = true
mouseUnlocker.Size = UDim2.new(0,0,0,0)
mouseUnlocker.Name = "mouseunlocker"
mouseUnlocker.Text = ""
end
local function lockMouse()
if script.Parent:FindFirstChild("Unlocker") then
script.Parent.Unlocker:Destroy()
end
end
humanoid.Died:connect(function()
print("died")
script.Parent.Parent.Enabled = true
unlockMouse()
end)
--- text button script
server script service script
local DataStoreService = game:GetService("DataStoreService")
local id = 11955511685
game.Players.CharacterAutoLoads = false
game.Players.PlayerAdded:Connect(function(plr)
print("player added")
plr:LoadCharacter()
local aliveplayers = Instance.new("ObjectValue",workspace.AlivePlayers)
aliveplayers.Name = plr.Name
aliveplayers.Value = plr
local hum = plr.Character:WaitForChild("Humanoid")
hum.Died:connect(function()
print("died")
local vale = workspace.AlivePlayers:FindFirstChild(plr.Name)
vale:Destroy()
end)
end)
function processReceipt(receiptInfo)
local player = game:GetService("Players"):GetPlayerByUserId(receiptInfo.PlayerId)
if not player then
return Enum.ProductPurchaseDecision.NotProcessedYet
end
if receiptInfo.ProductId == id then
print("player revived")
player:LoadCharacter()
local aliveplayers2 = Instance.new("ObjectValue",workspace.AlivePlayers)
aliveplayers2.Name = player.Name
aliveplayers2.Value = player
local hum = player.Character:WaitForChild("Humanoid")
hum.Died:connect(function()
print("died")
local aliveplayerss = workspace.AlivePlayers:FindFirstChild(player.Name)
aliveplayerss:Destroy()
end)
return Enum.ProductPurchaseDecision.PurchaseGranted
end
end
MarketplaceService.ProcessReceipt = processReceipt