I’m trying to make a part face towards where my HumanoidRootPart is facing but it gives me the error “LookVector cannot be assigned to” here is the script
local m6d = Instance.new("Motor6D", script.Parent)
m6d.Part1 = script.Parent
m6d.Part0 = c.HumanoidRootPart
script.Parent.CFrame.LookVector = c.HumanoidRootPart.CFrame.LookVector
All CFrame properties cannot be assigned to, you’ll need to set their CFrame to a newly constructed one.
CFrame.new(Position : Vector3, LookAt : Vector3)
could be used here, likewise:
CFrame.fromMatrix(Position : Vector3, RightVector : Vector3, UpVector : Vector3, LookVector? : Vector3)
An example of using fromMatrix would look like:
local Forward = (script.Parent.Position - c.CFrame.LookVector).Unit
local UnitUp = Vector3.fromAxis(Enum.Axis.Y)
local Right = Forward:Cross(Up)
local Up = Right:Cross(Forward)
script.Parent.CFrame = CFrame.fromMatrix(script.Parent.Position, Right, Up)
February 27, 2020, 1:01am
You have to use a constructor.
local pos = script.Parent.CFrame.Position
script.Parent.CFrame = CFrame.new(pos, pos + c.HumanoidRootPart.CFrame.LookVector)
it won’t face towards where my HumanoidRootPart is facing its still facing away from it.
February 27, 2020, 1:07am
script.Parent.CFrame = CFrame.new(pos, c.HumanoidRootPart.Position)
if you want it to look at the HRP