How could I make a lives system?

I’m going to make this as simple as possible, what i want is a lives system for the player in a game where they start with 3 lives, and when it gets to zero, a game over screen pops up, however, how do i make a local script make it so that the players live deplete as they die, but also make it so that they can also get lives back? Also, another thing but unnecessary, how would i make the game over like a 3d cutscene with the players character, but only happen to the players client and not to others or the server.

2 Likes

You could create a IntValue inside the Player when they join, create a Humanoid.Died Event, and handle the GUI Life System on the Client Side with the Changed Event

--Server Side
game.Players.PlayerAdded:Connect(function(Player)
    local Lives = Instance.new("IntValue")
    Lives.Name = "Lives"
    Lives.Value = 3
    Lives.Parent = Player
    
    Player.CharacterAdded:Connect(function(Character)
        Character.Humanoid.Died:Connect(function()
            Lives.Value -= 1
        end)
    end)
end)

And for the cutscene, you could use TweenService to lock the Player’s Camera in a certain position

3 Likes

so with the button, would i create an event that when the player presses it, it gives them 3 lives back?

and also i want the cutscene to be client only, due to the fact dont want other players seeing the cutscene or players game over at the same time seeing each others character

Yeah, you can use RemoteEvents if you’re doing it from the client side, so you can fire it to the server to change the Player’s Lives back to 3

That’s when you’d need a LocalScript to do the job, just place it in the StarterPack and do something like this (You’ll need to configure around a bit with it):

local Camera = workspace.CurrentCamera

Camera.CFrame = Vector3.new(0,0,0) --This will move the Local Player's Camera to the Worldpoint Origin, or the middle of the baseplate

also, how would i make the character that appear look like the players character, i tried looking before but nobody had info on how to make a character look like the player on the client

I found this, idk if it’ll help you