Answered by
8 years ago Edited 8 years ago
To do this, you're going to have to have some insight on CFrames.
There is a CFrame constructor that takes in 2 arguments:
- The Vector3 origin
- The Vector3 look point
Pretty self explanatory.
If you use the CFrame constructor, you can provide the brick's Position as the origin argument, and the mouse's hit Position as the look point. This will create a CFrame that is located at your object, and looking at your mouse.
Then all you have to do is apply the CFrame to a BodyGyro object.
01 | local plr = game.Players.LocalPlayer; |
02 | local mouse = plr:GetMouse(); |
03 | local obj = workspace.Part 1 ; |
05 | game:GetService( "RunService" ).RenderStepped:connect( function () |
07 | local cf = CFrame.new(obj.Position,mouse.Hit.p); |
09 | local bg = obj:FindFirstChild( "BodyGyro" ); |
11 | bg.P = obj:GetMass()* 1000 ; |
13 | bg.MaxTorque = Vector 3. new( 5000 , 5000 , 5000 ); |