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 = Instance.new("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
wait(col)
tap = false
else
debounce = false
for _, Character in pairs(char:GetChildren()) do
Character.Archivable = true
end
load:Play()
local fake = char:Clone()
fake.Name ="Fake"
fake.HumanoidRootPart.Position = char.HumanoidRootPart.Position
fake.Parent = game.Workspace
script.DashSound:Play()
char.HumanoidRootPart.Velocity = char.HumanoidRootPart.CFrame.lookVector* 100 --ok
wait(.3)
load:Stop()
debounce = true
end
end
end
end)
Thank you in advance for the help!