I made this, so far all it does is rotate randomly around the place. How can I make it so it will only rotate up and down?
01 | local plane = game.Workspace.Union |
02 | local player = game.Players.LocalPlayer |
03 | repeat wait() until player.Character |
04 | local character = player.Character |
05 | local mouse = player:GetMouse() |
06 |
07 | while true do |
08 | wait() |
09 | plane.CFrame = CFrame.new( plane.Position, Vector 3. new(- 90 ,- 90 ,mouse.Hit.p.Z)); |
10 | end |
You want the plane to ignore the mouse's Z position, to do this you supply the Vector3 with the planes Z position.
1 | plane.CFrame = CFrame.new(plane.Position, Vector 3. new(mouse.Hit.X, mouse.Hit.Y, plane.Position.Z)) |
The full code is supplied below, I've also add mouse.TargetFilter so the plane wont try to point at itself.
01 | local plane = workspace.Union |
02 | local player = game.Players.LocalPlayer |
03 | repeat wait() until player.Character |
04 | local character = player.Character |
05 | local mouse = player:GetMouse() |
06 | mouse.TargetFilter = plane -- Optional so the plane wont try point at itself |
07 |
08 | while wait() do |
09 | plane.CFrame = CFrame.new(plane.Position, Vector 3. new(mouse.Hit.X, mouse.Hit.Y, plane.Position.Z)) |
10 | end |
Althought TheDeadlyPanther's script will work it will result in the plane pointing either vertically upwards/downwards (Which I don't think you want?)
You're doing it wrong, so just do the following:
1 | plane.CFrame = CFrame.new( plane.Position, Vector 3. new(plane.CFrame.X,hit.p.Y,plane.CFrame.Z); -- if you want something to be the Y axis, keep it on the Y axis only |
Hope I helped :)
~TDP