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

How to prevent a player from spawning?

Asked by 9 years ago

I was wondering on how do some people prevent their characters from spawning.

game.Players.PlayerAdded:connect(function(player)
    player.CharacterAdded:connect(function(character)

1 answer

Log in to vote
14
Answered by 9 years ago

Take a look at this event Click here And this event Click here

This is a server side script not a localscript. Example of a delay for re -spawning:-

local respawnDelay = 15 -- delay time

game.Players.CharacterAutoLoads = false --Stop character auto load

game.Players.PlayerAdded:connect(function(player) -- new player in the game added

    player.CharacterAdded:connect(function(character) -- character sporns/ re-sporns

        local humanoid = character:FindFirstChild("Humanoid")  -- find humanoid in character

        if humanoid then -- humanoid is found

            humanoid.Died:connect(function() -- add a humanoid died event

                humanoid.Parent:Destroy() -- cleanup character or it will stay in the game

                wait(respawnDelay) -- wait for specified time
                player:LoadCharacter() -- load new character

            end)
        end     

    end)

    wait(respawnDelay) -- delay for new player when they join the game
    player:LoadCharacter() -- load character
end)

Hope this helps.

1
Thanks :D SomeoneYetUnnoticed 31 — 9y
Ad

Answer this question