Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

CFraming with Advanced Problems?

Asked by 6 years ago

Hi i'm struggling to make a part point to a part on a particular two axis. I want the part to face a point only on the X,Z Axis. I've tried particular methods but they don't work out the way I want them to.

local Distance = (workspace.Look.Position - script.Parent.Position)
    local SpinZ = math.atan2(Distance.Y,Distance.X) + math.pi
    local SpinY = math.atan2(Distance.X,Distance.Z) + math.pi
    local SpinX = math.atan2(Distance.Y,Distance.Z) + math.pi
    script.Parent.CFrame = CFrame.new(script.Parent.Position)  *    CFrame.Angles(SpinX,0,SpinZ)

Answer this question