Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

How to prevent a player from spawning?

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

✓ Accepted answer

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 comment

1

Thanks :D

This discussion is preserved as it was. New answers, comments, and votes are closed.