I’ve never played around with CFrames and I have no clue how to approach this problem. I’ve tried to use ToObjectSpace but that didn’t return the correct results(probably the way I applied it). I’m ray casting and I want the model to face the same direction of the ray and also move to where the ray hit. I’m looking for the best way to do this.
Here is the script:
game:GetService("RunService").Heartbeat:Connect(function()
--Ray calculation
local ray = Ray(humanPosition.Position, CFrame.new(humanPosition.Position, game.Workspace.Part.Position).lookVector * 1)
local hit, position = Workspace:FindPartOnRayWithWhitelist(ray, {}, true)
local cframe = CFrame.new(humanPosition.Position, position)
human:SetPrimaryPartCFrame(cframe)
wait()
end)
The current cframe here just looks at the part; the human doesn’t move to it. I’m trying to move the human and make it look in the same direction as the ray.