Why do I not respawn?

So I had help by a different developer that helped me prevent a player from spawning until they press a button.

Script

--Client Side
local Player = game.Players.LocalPlayer
local Camera = workspace.CurrentCamera
local light = game.Lighting.Blur
local music = game.SoundService["When U Coming Back - NoVocals"]

local PlayButton = script.Parent.TextButton
local frame = script.Parent.Frame
local text = script.Parent.TextLabel

repeat wait()
	Camera.CameraType = Enum.CameraType.Scriptable
until Camera.CameraType == Enum.CameraType.Scriptable
Camera.CFrame = workspace.CameraPart.CFrame

music:Play()

PlayButton.MouseButton1Click:Connect(function()
	Camera.CameraType = Enum.CameraType.Custom
	PlayButton:Destroy()
	frame.Visible = false
	text:Destroy()
	light:Destroy()
	music:Stop()

	game.ReplicatedStorage.LoadCharacter:FireServer() 
end)
--Server Side
game.Players.CharacterAutoLoads = false 

game.Players.PlayerAdded:Connect(function(Player)
	Player:LoadCharacter()
	repeat wait() until Player.Character:FindFirstChild("Humanoid") -- Loaded Character Humanoid
	Player.Character.Parent = game.ServerStorage -- Store It
end)

game.ReplicatedStorage.LoadCharacter.OnServerEvent:Connect(function(Player)
	repeat wait() until game.ServerStorage:FindFirstChild(Player.Character.Name)
	game.ServerStorage:FindFirstChild(Player.Character.Name).Parent = game.Workspace
	print("LoadedCharacter")
end)

SO my problem here is when I reset, I only see my dead body and don’t respawn.

1 Like

So wait I’m confused you’re wanting the player to respawn when they press a button only once when they join or is it every time.

This code is only effective for the first join. There’s no respawn logic written to take over Roblox’s default spawning logic so yeah, naturally your character won’t respawn. Always why I recommend a good read of the API and to understand the code you’re working with to be able to debug these problems.

Since CharacterAutoLoads is false the developer needs to explicitly control respawning. This is handled for the first join at least (albeit in a messy manner) but not for all other cases. There’s no check for the death of a character nor any respawn logic implemented.

If you don’t want the character to spawn into the map when they first join, then really there are two better options that you can work with instead. They are all effective on first join.

  • Move the character to a spawn box.
  • Destroy the character when they first join and when the character is added.

This way, you aren’t disabling Roblox’s default spawn logic while still getting the intended end result.

There is no LoadCharacter() on the server side.

game.ReplicatedStorage.LoadCharacter.OnServerEvent:Connect(function(Player)
	repeat wait() until game.ServerStorage:FindFirstChild(Player.Character.Name)
	game.ServerStorage:FindFirstChild(Player.Character.Name).Parent = game.Workspace
	print("LoadedCharacter")
end)

only once they join. (ufasdgfoiuagoifugaosiudg)