Cloning my character won't work?

I want to clone my character, when he performs a movement(dash)

But when I try to run the script this error occurs: fake is a nil value

I’ve seen on previous posts that archivable of the player’s character has to be set true first. I’ve tried it but it still doesn’t work. It can also be that I messed up setting it to true.
But when testing the game I saw that everything is archivable.

local plr = game.Players.LocalPlayer
local char = plr.Character or plr.CharacterAdded:Wait()
local humanoid = char.Humanoid
local UIS = game:GetService("UserInputService")

local Anim ="Animation")
Anim.AnimationId = 'rbxassetid://3298637667'
local load = humanoid:LoadAnimation(Anim)
local tap = false
local col = 0.25
local debounce = true

UIS.InputBegan:Connect(function(Input, GameStuff)
 	if GameStuff then return end
 		if Input.KeyCode == Enum.KeyCode.W then
			if debounce then
  				if not tap then
   					tap = true
   					tap = false
					debounce = false
					for _, Character in pairs(char:GetChildren()) do
	    			Character.Archivable = true

					local fake = char:Clone()
					fake.Name ="Fake"
					fake.HumanoidRootPart.Position = char.HumanoidRootPart.Position
					fake.Parent = game.Workspace
   					char.HumanoidRootPart.Velocity = char.HumanoidRootPart.CFrame.lookVector* 100 --ok
					debounce = true

Thank you in advance for the help!

Try name char into something else, it might be that you’re using the datatype char instead :confused:

1 Like

This is a common topic. This is what you are looking for:

You basically have to set your character’s Archivable setting to true before you can clone it. If this is the fix, make sure to use the search tool before making a topic that has been made multiple times before.


your problem is this:

for _, Character in pairs(char:GetChildren()) do
     Character.Archivable = true

you need to change the model itself to archivable, not everything inside of it. When I did that, it worked, so instead of your loop code, just do:

char.Archivable = true

You should be good after that. Hoped this helped and make sure to click the solution button (:white_check_mark:) if this solved your problem. :grin:

To go along with this, like what @BruiseIgnio said, make sure you search for answers before asking questions, there were answers on this you could have found like in the article he provided.


Thank you, it works now. I was too stupid to realize that the model itself also has to be archivable not just the parts inside.

Or you could just define character and use the clone method Fake:Clone() Fake.Position = Character.Position