Attempt to index with nil 'CFrame'. I have this error in kill script. How can i fix it?
local Copy = script.Parent:Clone() local NPC = script.Parent local Humanoid for i,v in pairs(NPC:GetChildren()) do if v:IsA('bot') then Humanoid = v end end script.Parent.Touched:connect(function(hit) if hit and hit.Parent and hit.Parent:FindFirstChild("Humanoid") then hit.Parent.Humanoid.Health = 0 local character = hit.Parent local KnockBack = Instance.new("BodyVelocity") KnockBack.P = math.huge KnockBack.Parent = character:FindFirstChild("HumanoidRootPart") KnockBack.MaxForce = Vector3.new(math.huge,math.huge,math.huge) KnockBack.Velocity = character:FindFirstChild("HumanoidRootPart").CFrame.lookVector * -132 game.Debris:AddItem(KnockBack, 0.5) else if hit.Name == "Detector" then Copy.Parent = NPC.Parent Copy:MakeJoints() NPC:Destroy() end end end)
From the sample of code you have provided, it seems that the variable character
does not have a Child called HumanoidRootPart
, so you should find what character
does have and use that instead. For example, if your game is in R6 I believe it should be Torso
instead.