Attempt to index nil with CFrame

Why is this happening, can someone help

local cframe = char:WaitForChild('HumanoidRootPart').CFrame
local root = CharacterClone:FindFirstChild("HumanoidRootPart")
root.CFrame = cframe --Error here

Screen Shot 2021-04-07 at 5.38.46 PM
Thank you


Perhaps the root didn’t exist when :FindFirstChild(“HumanoidRootPart”) ran, I would use :WaitForChild() instead.

That just Infinite yields

Can we also see how you defined ‘char’, please?

Ill just give the full if their is anything else you want to know

		for i, v in pairs(game.ReplicatedStorage:GetChildren()) do
			if EquippedVal.Value == v.Name then
				local CharacterClone = v:Clone()
				CharacterClone.Name = player.Name
				local cframe = char:WaitForChild('HumanoidRootPart').CFrame
				player.Character = CharacterClone
				local root = CharacterClone:WaitForChild("HumanoidRootPart")
				local hum = CharacterClone:FindFirstChild("Humanoid")
				root.CFrame = cframe
				CharacterClone.Parent = game.Workspace

Is CharacterClone defined exactly as it is in the Explorer?


try this: no need to set the humanoids root to its own cframe anway.

local root= char:WaitForChild('HumanoidRootPart')
local cframe = rootpart.CFrame
1 Like

why did you use rootpart? Should i replace with root?

you put root in the first script at the top

Oh i read it wrong I see the problem

Still doesn’t do anything, same error

Are you sure there is a ‘HumanoidRootPart’ inside the cloned character?

When you click on the error in studio, what line does it bring you to and what is that line of code


is the error still the same? as it was before


That mean that the root part doesnt have a cframe? strange

Well, you see, when :WaitForChild() infinitely yields, that means that it can’t find that specific part. Could you show us how CharacterClone looks like?

1 Like