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:

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

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:

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)

Answer this question