Custom Character not working?

Hello,
I’m trying to make a custom character for each team. But, it doesn’t seem to be working
Script:

local Teams = game:GetService("Teams")
local Characters = game:GetService("ServerStorage"):WaitForChild("Characters")
local Character1 = Characters.1:WaitForChild("StarterCharacter"):Clone()
local Character2 = Characters.2:WaitForChild("StarterCharacter"):Clone()

game.Players.PlayerAdded:Connect(function(player)
	player.CharacterAdded:Connect(function(character)
		if player.Team == Teams.Red then
			Red.Parent = workspace
			Red:MoveTo(character:WaitForChild("HumanoidRootPart").Position)
			character = Red
		elseif player.Team == Teams.Blue then
			Blue.Parent = workspace
			Blue:MoveTo(character:WaitForChild("HumanoidRootPart").Position)
			character = Blue
		end
	end)
end)

Any help is apricated thank you.

1 Like
local teams = game:GetService("Teams")
local players = game:GetService("Players")
local Characters = game:GetService("ServerStorage"):WaitForChild("Characters")

players.PlayerAdded:Connect(function(player)
	player.CharacterAdded:Connect(function(character)
		if player.Team == teams.Red then
			local Red = Characters:WaitForChild("1"):WaitForChild("StarterCharacter"):Clone()
			Red.Parent = workspace
			Red:MoveTo(character:WaitForChild("HumanoidRootPart").Position)
			Red.Parent = character
		elseif player.Team == teams.Blue then
			local Blue = Characters:WaitForChild("2"):WaitForChild("StarterCharacter"):Clone()
			Blue.Parent = workspace
			Blue:MoveTo(character:WaitForChild("HumanoidRootPart").Position)
			Blue.Parent = character
		end
	end)
end)

I believe this is what you’re trying to achieve, you may want to weld the StarterCharacter to the player’s character model.

In practically all programming languages, having an object named as a Number is a huge no-no.

Numbers are practically special characters in a programming language, used mostly for arithmetic or accessing tables.

So when a variable name starts with a number…

local 1a = “some value”
--or
local a = workspace.1

You will get an error.

The same is true when trying to grab something in workspace that has a name that starts with a number.

You can get around this using similar methods as mentioned above…

local a = workspace:WaitForChild(“1”)
local b = workspace:FindFirstChild(“1”)
local c = workspace[“1”]

The above will work…

But naming objects that start with a number is generally bad practice.

2 Likes

It doesn’t seem to be making my character the model. It just clones the model to me and moves it to my character position. Even with welding it still has the same outcome.

After doing some testing. I realized my custom character is the problem. I tried using a dummy and it worked, but not my character. Any idea how to fix this?