StarterCharacter isn't respawning after reset

The problem I’m having is with my character not resetting after the reset, but it’s not that simple.

  • ServerScript | ServerScriptService
local ServerStorage = game:GetService("ServerStorage")
local StarterPlayer = game:GetService("StarterPlayer")
local Teams = game:GetService("Teams")

local StarterCharacterScripts = StarterPlayer:WaitForChild("StarterCharacterScripts")
local CustomCharacters = ServerStorage:WaitForChild("CustomCharacters")
local StarterChildren = StarterCharacterScripts:GetChildren()

local GARspawn = game.Workspace.Outros.Spawn:WaitForChild("GAR").CFrame
local TrooperMorph = CustomCharacters:FindFirstChild("Trooper")
local SpecialistMorph = CustomCharacters:FindFirstChild("Specialist")
local CorporalMorph = CustomCharacters:FindFirstChild("Corporal")
local SergeantMorph = CustomCharacters:FindFirstChild("Sergeant")
local StaffSergeantMorph = CustomCharacters:FindFirstChild("StaffSergeant")
local MasterSergeantMorph = CustomCharacters:FindFirstChild("MasterSergeant")
local CommandSergeantMorph = CustomCharacters:FindFirstChild("CommandSergeantMajor")
local WarrantOfficerMorph = CustomCharacters:FindFirstChild("WarrantOfficer")
local UpperWarrantOfficerMorph = CustomCharacters:FindFirstChild("UpperWarrantOfficer")
local ChiefWarrantOfficerMorph = CustomCharacters:FindFirstChild("ChiefWarrantOfficer")

local EventFolder = game.Workspace.Outros.Eventos
local GAR = EventFolder:FindFirstChild("GAR")

-- Trooper & Specialist
GAR.OnServerEvent:Connect(function(player, itemName)
	if itemName == "Trooper" then
		player.Team = Teams.GAR
		local NewCharacter = TrooperMorph:Clone()
		NewCharacter.Name = player.Name
		for i, item in pairs(StarterChildren) do
			item:Clone().Parent = NewCharacter
		end
		if player.Team == Teams.GAR then
			NewCharacter.HumanoidRootPart.CFrame = GARspawn
		end
		player.Character = NewCharacter
		NewCharacter.Parent = workspace
	end
	if itemName == "Specialist" then
		player.Team = Teams.GAR
		local NewCharacter = SpecialistMorph:Clone()
		NewCharacter.Name = player.Name
		for i, item in pairs(StarterChildren) do
			item:Clone().Parent = NewCharacter
		end
		if player.Team == Teams.GAR then
			NewCharacter.HumanoidRootPart.CFrame = GARspawn
		end
		player.Character = NewCharacter
		NewCharacter.Parent = workspace
	end
end)

-- Corporal & Sergeant
GAR.OnServerEvent:Connect(function(player, itemName)
	game.Players.CharacterAutoLoads = false
	if itemName == "Corporal" then
		player.Team = Teams.GAR
		local NewCharacter = CorporalMorph:Clone()
		NewCharacter.Name = player.Name
		for i, item in pairs(StarterChildren) do
			item:Clone().Parent = NewCharacter
		end
		if player.Team == Teams.GAR then
			NewCharacter.HumanoidRootPart.CFrame = GARspawn
		end
		player.Character = NewCharacter
		NewCharacter.Parent = workspace
	end
	if itemName == "Sergeant" then
		player.Team = Teams.GAR
		local NewCharacter = SergeantMorph:Clone()
		NewCharacter.Name = player.Name
		for i, item in pairs(StarterChildren) do
			item:Clone().Parent = NewCharacter
		end
		if player.Team == Teams.GAR then
			NewCharacter.HumanoidRootPart.CFrame = GARspawn
		end
		player.Character = NewCharacter
		NewCharacter.Parent = workspace
	end
end)

-- Staff Sergeant & Master Sergeant
GAR.OnServerEvent:Connect(function(player, itemName)
	game.Players.CharacterAutoLoads = false
	if itemName == "StaffSergeant" then
		player.Team = Teams.GAR
		local NewCharacter = StaffSergeantMorph:Clone()
		NewCharacter.Name = player.Name
		for i, item in pairs(StarterChildren) do
			item:Clone().Parent = NewCharacter
		end
		if player.Team == Teams.GAR then
			NewCharacter.HumanoidRootPart.CFrame = GARspawn
		end
		player.Character = NewCharacter
		NewCharacter.Parent = workspace
	end
	if itemName == "MasterSergeant" then
		player.Team = Teams.GAR
		local NewCharacter = MasterSergeantMorph:Clone()
		NewCharacter.Name = player.Name
		for i, item in pairs(StarterChildren) do
			item:Clone().Parent = NewCharacter
		end
		if player.Team == Teams.GAR then
			NewCharacter.HumanoidRootPart.CFrame = GARspawn
		end
		player.Character = NewCharacter
		NewCharacter.Parent = workspace
	end
end)

-- Command Sergeant Mayor & Warrant Officer
GAR.OnServerEvent:Connect(function(player, itemName)
	game.Players.CharacterAutoLoads = false
	if itemName == "CommandSergeant" then
		player.Team = Teams.GAR
		local NewCharacter = CommandSergeantMorph:Clone()
		NewCharacter.Name = player.Name
		for i, item in pairs(StarterChildren) do
			item:Clone().Parent = NewCharacter
		end
		if player.Team == Teams.GAR then
			NewCharacter.HumanoidRootPart.CFrame = GARspawn
		end
		player.Character = NewCharacter
		NewCharacter.Parent = workspace
	end
	if itemName == "WarrantOfficer" then
		player.Team = Teams.GAR
		local NewCharacter = WarrantOfficerMorph:Clone()
		NewCharacter.Name = player.Name
		for i, item in pairs(StarterChildren) do
			item:Clone().Parent = NewCharacter
		end
		if player.Team == Teams.GAR then
			NewCharacter.HumanoidRootPart.CFrame = GARspawn
		end
		player.Character = NewCharacter
		NewCharacter.Parent = workspace
	end
end)

-- Upper Warrant Officer & Chief Warrant Officer
GAR.OnServerEvent:Connect(function(player, itemName)
	game.Players.CharacterAutoLoads = false
	if itemName == "UpperWarrantOfficer" then
		player.Team = Teams.GAR
		local NewCharacter = UpperWarrantOfficerMorph:Clone()
		NewCharacter.Name = player.Name
		for i, item in pairs(StarterChildren) do
			item:Clone().Parent = NewCharacter
		end
		if player.Team == Teams.GAR then
			NewCharacter.HumanoidRootPart.CFrame = GARspawn
		end
		player.Character = NewCharacter
		NewCharacter.Parent = workspace
	end
	if itemName == "ChiefWarrantOfficer" then
		player.Team = Teams.GAR
		local NewCharacter = ChiefWarrantOfficerMorph:Clone()
		NewCharacter.Name = player.Name
		for i, item in pairs(StarterChildren) do
			item:Clone().Parent = NewCharacter
		end
		if player.Team == Teams.GAR then
			NewCharacter.HumanoidRootPart.CFrame = GARspawn
		end
		player.Character = NewCharacter
		NewCharacter.Parent = workspace
	end
end)

image

Ignore the others custom characters, I’m testing it by the Trooper Morph which is located in Trooper Event

If anyone has any idea about this, please do not ignore.

Still require assistance!21w112121212121212

When you enable CharacterAutoLoads, it doesn’t automatically load all of the player’s characters. You need to do it manually. When you want to respawn the character do this:

player:LoadCharacter() -- respawns the character regardless of if it exists or not

As for advice on how to make an enticing topic, don’t start with the phrase “it’s not that simple” because you may be wrong and it will push others away. In this case, the solution was simply one line of code.

Well, I’m not exactly the english naural speaker so I’ve used google translator but thanks for the suggestion and thanks for the help.

1 Like

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.