Answered by
ee0w 458
6 years ago
Eh, you need some CFrame witchcraft. But it's fairly simple to do!
One of the constructors of a CFrame is as follows:
CFrame.new ( Vector3 Position, Vector3 LookAt )
For example:
1 | CFrame.new(Vector 3. new( 0 , 10 , 0 ), Vector 3. new( 5 , 0 , 0 )) |
Will create a CFrame located at {0, 10, 0}
, oriented towards {5, 0, 0}
. And that's all! Now all that's left is to plug in what you know already:
2 | local mouse = game.Players.LocalPlayer:GetMouse() |
3 | local part = workspace.Part |
5 | mouse.Move:Connect( function () |
6 | part.CFrame = CFrame.new(part.Position,mouse.Hit.Position) |
Hope I helped!