Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

Why is HumanoidRootPart a nil value?

Asked by
proo34 41
5 years ago
local plr = game.Players.LocalPlayer
repeat wait() until plr and plr.Character
local mouse = plr:GetMouse()
local mtarget
local down
local UTplr

game.Players.PlayerAdded:Connect(function(Player)
    Player.CharacterAdded:Connect(function(Character)
        UTplr = Character:WaitForChild("HumanoidRootPart")
    print(UTplr.CFrame)
    end)
end)

function normOBJ (v) return v / v.Magnitude end


mouse.Button1Down:connect(function()
 if mouse.Target ~= nil and mouse.Target.Locked == false and mouse.Target.Name == "CinderBlock" or mouse.Target.Name == "SodaCan" then
  print(mouse.Target.Name)
  mtarget = mouse.Target
  down = true
  mouse.TargetFilter = mtarget or mouse.Target
  end
end)



mouse.Move:Connect(function()
 if down == true and mtarget ~= nil then

local mvector = UTplr.CFrame.VectorToObjectSpace(mouse.Hit.LookVector)
if  mvector > 3 then
    mtarget.Position = UTplr.CFrame(normOBJ(mvector) * 3)
else
    mtarget.Position = UTplr.CFrame.VectorToWorldSpace(mvector)
end

 end

end)


mouse.Button1Up:connect(function()
 down = false
 mouse.TargetFilter = nil
 mtarget = nil
end)

That is the script, it allows me to pick up objects but it wont work because HumaniodRootPart is a nil value. I don't understand, may I have some help?

0
R15 or R6? sahadeed 87 — 5y

Answer this question