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

Why does it attempt to index nil with parent?

Attempt To Index Nil With Parent

game.Players.PlayerAdded:Connect(function(plr)
	repeat wait() until plr.Character
	local character = plr.Character
	local Mimic = plr.Character:Clone()
	Mimic.Parent =  workspace
	Mimic.Head.Size = Vector3.new(10,10,10)
end)

3 answers

✓ Accepted answer

Example

game.Players.PlayerAdded:Connect(function(player)
	player.CharacterAdded:Connect(function(character)
		print(character.Name.." character has loaded in")
	end)
end)

1 comment

0

How come this comment got downvoted?

Good question, it's because the character has its 'Archivable' property false by default. That means you shouldn't be able to clone it in the first place therefore when you attempted to clone the character, it gave you 'nil' or nothing in return and as we all know nothing has no parent.

Add this line before cloning the character: plr.Character.Archivable = true

You need to do game.Workspace since the Workspace is inside of the game and also use the CharacterAdded function instead of the repeat wait.

game.Players.PlayerAdded:Connect(function(plr)
plr.CharacterAdded:Connect(function(char)
	    local Mimic = plr.char:Clone()
            Mimic.Parent = game.Workspace
	    Mimic.Head.Size = Vector3.new(10,10,10)
	end)
end)

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