Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

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

Asked by 8 years ago

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:

01local chartemplate = game.ReplicatedStorage.CharacterTemplate
02 
03game.Players.PlayerAdded:connect(function(Player)
04    Player.CharacterAdded:connect(function(Char)
05        AddChar(Player, Char)
06    end)
07end)
08function AddChar(Player, Char)
09    if not Player.Parent then return end
10    local NewChar = chartemplate
11    NewChar.Name = Player.Name
12    if Player.Character then
13        Player.Character:Destroy()
14    end
15    Player.Character = NewChar
16    NewChar.Parent = game.Workspace
17end

2 answers

Log in to vote
0
Answered by 8 years ago

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

Ad
Log in to vote
0
Answered by 8 years ago

Try this:

01local chartemplate = game.ReplicatedStorage.CharacterTemplate
02 
03function AddChar(Player, Char)
04if not Player then return end
05local NewChar = chartemplate
06NewChar.Name = Player.Name
07if Char then
08Char:remove()
09end
10Player.Character = NewChar
11NewChar.Parent = workspace
12 
13game.Players.PlayerAdded:connect(function(Player)
14Player.CharacterAdded:connect(function(Char)
15 AddChar(Player, Char)
16 end)
17end)

Answer this question