Ad
Still have questions? Join our Discord server and get real time help.
Log in to vote
4

How to prevent a player from spawning?

Asked by 3 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
12
Answered by
kingdom5 4777 Trusted Snack Break Moderation Voter Community Moderator
3 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.

0
Thanks :D SomeoneYetUnnoticed 25 — 3y
Ad

Answer this question