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

Why is the clone of the character nil?

Here's my code in a server script:

local Players = game:GetService("Players")

Players.PlayerAdded:Connect(function(player)
	local char = player.Character or player.CharacterAdded:Wait()
	local clone = char:Clone()
	local root = clone:WaitForChild("HumanoidRootPart")
	local char1 = workspace:WaitForChild("char1")
	root.CFrame = char1:WaitForChild("HumanoidRootPart").CFrame
end)

I've tried so many things that I just cannot remember anything I've tried. Here's the error that pops up: ServerScriptService.Script:6: attempt to index nil with 'WaitForChild'. Apologies if this is a stupid question, this has just been bothering me so much.

1 answer

✓ Accepted answer

Player Character models are not archivable by default; if you set it so they are, then it would not be nil.

Here is a script you can put in the workspace that will make characters archivable by default

game.Players.PlayerAdded:Connect(function(plr)
plr.CharacterAdded:Connect(function()
plr.Character.Archivable = true
end)
end)

1 comment

0

Ah! I didn't know this. Thanks!

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