local Players = game:GetService("Players")
Players.PlayerAdded:Connect(function(player)
local stats = Instance.new("Folder")
stats.Name = "leaderstats"
stats.Parent = player
local lives = Instance.new("IntValue")
lives.Name = "Lives"
lives.Value = 3
lives.Parent = stats
end)Players.PlayerAdded:Connect(function(player)
player.CharacterAdded:Connect(function(character)
local humanoid = character:WaitForChild("Humanoid")
humanoid.Died:Connect(function()
local lives = player.leaderstats:FindFirstChild("Lives")
if lives then
lives.Value = lives.Value - 1
end
end)
end)
end)if lives.Value <= 0 then
print("Игра окончена")
-- отключаем респавн
player.CharacterAutoLoads = false
endhumanoid.Died:Connect(function()
local lives = player.leaderstats.Lives
if lives.Value > 0 then
wait(3)
player:LoadCharacter()
end
end)local Players = game:GetService("Players")
Players.PlayerAdded:Connect(function(player)
local stats = Instance.new("Folder")
stats.Name = "leaderstats"
stats.Parent = player
local lives = Instance.new("IntValue")
lives.Name = "Lives"
lives.Value = 3
lives.Parent = stats
player.CharacterAdded:Connect(function(character)
local humanoid = character:WaitForChild("Humanoid")
humanoid.Died:Connect(function()
lives.Value -= 1
if lives.Value > 0 then
wait(3)
player:LoadCharacter()
else
print(player.Name .. " проиграл")
player.CharacterAutoLoads = false
end
end)
end)
end)lives.Value = lives.Value + 1