for i, v in pairs(workspace.Items:GetChildren()) do
if EquippedVal.Value == v.Name then
local CharacterClone = v:Clone()
print("Cloned")
CharacterClone.Name = player.Name
print(CharacterClone.Name)
local cframe= player.Character.HumanoidRootPart.CFrame --This is where the problem is
player.Character:Destroy()
print("Destroyed")
player.Character = CharacterClone
print("Nearly")
local root = CharacterClone:WaitForChild("HumanoidRootPart")
local hum = CharacterClone:WaitForChild("Humanoid")
wait()
root.CFrame = cframe
CharacterClone.Parent = game.Workspace
end
end
end
In your output it is showing that the character is added after your error. Attempt to index nil with ________ means in this case that your character doesn’t exist yet (character is nil).
Try moving this code into the portion of your script where it knows when the character is loaded in. I guess you can also wait until the character is not nil by checking before you do stuff with it.