AC:SetPrimaryPartCFrame(CFrame.lookAt(Vector3.new(math.random(-400,400),math.random(200,250),math.random(-400,400)),part.Position.Z))
How would I get this line of code to look at the target part only in the Y axis?
AC:SetPrimaryPartCFrame(CFrame.lookAt(Vector3.new(math.random(-400,400),math.random(200,250),math.random(-400,400)),part.Position.Z))
How would I get this line of code to look at the target part only in the Y axis?
If you want it on one axis, leave x and z empty, and only have values for y.
AC:SetPrimaryPartCFrame(CFrame.lookAt(Vector3.new(0,math.random(200,250),0)),part.Position.Z))
This might not be it, but.
local start = Vector3.new(math.random(-400,400), math.random(200,250), math.random(-400,400))
local lookAtPosition = Vector3.new(part.Position.X, start.Y, part.Position.Z)
local lookCFrame = CFrame.lookAt(start, lookAtPosition)
AC:SetPrimaryPartCFrame(lookCFrame)
Also, I highly reccomend not trying to put a lot of code on a single line. As it can make the code harder to read for yourself (and others). I say this from experience.
Taking each “value” and giving it it’s own variable helps a lot with readability.
When you do try to jam a lot of things on a single line, you are more prone to ending up making tiny mistakes, and they also become harder to spot. Because you now have to keep track of all the parentheses as you read from left to right.
This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.