Essentially, I have this turret and it is working fine excpet for the gun iteslf. \The turret workss by rotationg on its base to face the target. Then, the gun will use an x rotation to face the target so it can shoot. How would i go about calculating the angle i need for the gun thing to face the target, after the base is facing its zy coordinates? Once again, gun can only rotate on x axis.
Help is needed, thx.
You could probably construct a CFrame using CFrame.new(Vector3 Pos, Vector3 Lookat)
and if you want to lock any axis, do:
local pos = Vector3.new() -- set these variables accordingly local Lookat = Vector3.new() local turret = workspace.Turret -- The turret local facing = CFrame.new(pos, Lookat) -- set turret's CFrame to facing -- extract the orientation, set Y and Z rotation to a fixed number or whatever axis's you want locked -- once those are set, you have rotation on only the X axis.