Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
1

Player auto loads?

Asked by 10 years ago

Is there a way to stop players from auto magically responding once their health hits 0 is this possible?

1 answer

Log in to vote
1
Answered by
iaz3 190
10 years ago

Yes, look at CharacterAutoLoads

Example code from the page:

local respawnTime = 5

local Players = Game:GetService("Players")
Players.CharacterAutoLoads = false

Players.PlayerAdded:connect(function(Player)
    Player.CharacterAdded:connect(function(Character)
        -- find the humanoid, and detect when it dies
        local Humanoid = Character:FindFirstChild("Humanoid")
        if Humanoid then
            Humanoid.Died:connect(function()
                -- delay, then respawn the character
                wait(respawnTime)
                Player:LoadCharacter()
            end)
        end
    end)

    Player:LoadCharacter() -- load the character for the first time
end)
Ad

Answer this question