Hi devs I am having some trouble cloning the players character whenever I do so it returns nil
local UIS = game:GetService("UserInputService")
local rs = game:GetService("RunService")
local plr = game:GetService("Players").LocalPlayer
local PlayerModule = require(game.Players.LocalPlayer.PlayerScripts:WaitForChild("PlayerModule"))
local Controls = PlayerModule:GetControls()
local char = plr.Character
local humanoid = char:WaitForChild("Humanoid")
local HRP = char:WaitForChild("HumanoidRootPart")
local clone = char:Clone()
local bv = Instance.new("BodyVelocity")
local cam = game.Workspace.CurrentCamera
local open = false
UIS.InputBegan:connect(function(input, cindex)
if input.KeyCode == Enum.KeyCode.M and open == false then
bv = Instance.new("BodyVelocity")
open = true
bv.Parent = HRP
bv.MaxForce = Vector3.new(99999, 99999, 99999)
bv.Velocity = Vector3.new(0, 0, 0)
print(clone.Name)
clone["Origin Position"] = HRP.Position
clone.Parent = game.Workspace
local children = char:GetChildren()
for i = 1, #children do
print(i, children[i].Name)
if children[i]:IsA("Part") then
children[i].Transparency = 1
end
end
elseif input.KeyCode == Enum.KeyCode.M then
bv:Destroy()
open = false
humanoid.WalkSpeed = 16
cam.CameraSubject = HRP
end
end)
rs.RenderStepped:Connect(function()
if open == true then
local Velocity = humanoid.MoveDirection* Vector3.new(50, 0, 50) + game.Workspace.CurrentCamera.CoordinateFrame.lookVector * Vector3.new(0, 50, 0)
bv.Velocity = Velocity
end
end)