So here I have a script, that points an object towards a position.
function lookAt(target, eye)
local forwardVector = (eye - target).Unit
local upVector = Vector3.new(0, 1, 0)
-- You have to remember the right hand rule or google search to get this right
local rightVector = forwardVector:Cross(upVector)
local upVector2 = rightVector:Cross(forwardVector)
return CFrame.fromMatrix(eye, rightVector, upVector2)
end
game:GetService("RunService").Stepped:Connect(function()
--workspace.Part.CFrame = initial:lerp(target, math.min((tick() - s) / TIME, 1))
workspace.Part.CFrame = lookAt(Vector3.new(0, 0, 0), workspace.Part.Position)
end)
But when I position the brick, exactly where I want it to point towards (Vector3.new(0, 0, 0)) this happens:
The brick disappears, and when I click on the brick in the explorer window, then press " f " The viewport goes black. Is there anything I can do to fix this?
This seems be an edge case problem, the lookAt function the wiki provides isn’t really great Maybe try the one Egomose gave in this post:
I’ve tested your code but using the LookAt function from the wiki and it did the same thing for me as it did for you, and then i tested the one Ego provided and it worked as expected, so yeah this is likely an Edge Case issue