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

Custom character script won't work, what did I do wrong?

So, I'm working on a game and I made a custom character, but it won't work! The problem is that I get the error "The Parent property of Player1 is locked, current parent: NULL, new parent Workspace" after I see a message that says "Creating Player". What did I do wrong? Here is the script:

local chartemplate = game.ReplicatedStorage.CharacterTemplate

game.Players.PlayerAdded:connect(function(Player)
	Player.CharacterAdded:connect(function(Char)
		AddChar(Player, Char)
	end)
end)
function AddChar(Player, Char)
	if not Player.Parent then return end
	local NewChar = chartemplate
	NewChar.Name = Player.Name
	if Player.Character then
		Player.Character:Destroy()
	end
	Player.Character = NewChar
	NewChar.Parent = game.Workspace
end

2 answers

Try Making chartemplate at the begining at Local chartemplate<----Needs To Be Upercased Try That

Try this:

local chartemplate = game.ReplicatedStorage.CharacterTemplate

function AddChar(Player, Char)
if not Player then return end
local NewChar = chartemplate
NewChar.Name = Player.Name
if Char then
Char:remove()
end
Player.Character = NewChar
NewChar.Parent = workspace

game.Players.PlayerAdded:connect(function(Player)
Player.CharacterAdded:connect(function(Char)
 AddChar(Player, Char)
 end)
end)

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