The following code prints:
0, -15, 90 | 0, 0, 0
0, 0, 0 | 0, 0, 0
but the turret is not rotating at all.
while true do
if target.Value ~= nil then
local v = CFrame.new(turret.Position, target.Value.Position):VectorToObjectSpace()
print(turret.Orientation, v)
turret.Orientation = v
print(turret.Orientation, v)
end
wait(1/20)
end
Sorry, i’m complexly lost in CFrames. They use a different rotational system than the ‘Rotation’ option on Baseparts? How do I pick out one axis from the rotation of a CFrame and apply it to a Basepart?
Here, this is what I’m trying to do but now i’m having trouble converting values, and it’s still being glitchy as well.
while true do
if target.Value ~= nil then
local n = CFrame.new(turret.Position, target.Value.Position):()
local weld = turret:FindFirstChildWhichIsA('Weld')
weld.C1 = weld.C1 * CFrame.fromAxisAngle(0, n.Y, 0)
break
end
wait(1/20)
end
I’m not sure what you’re trying to do here. On the third line, you have a :() that doesn’t do anything. On the fifth line, I don’t think you’re using fromAxisAngle correctly. Also, what do you mean that it’s being glitchy?
Anyway, this post piqued my interest so I had a go at it myself.