[EDIT] I managed to used 'for i' loop and CFrame to do what I needed to do.
Sorry if the title was misleading cause I have no idea what title to give it
I need help trying to do an if then break loop. Like if a part reaches a specific coordinate, it will break the loop which makes it stop moving.
Here is my script and at line 10, it underlines the '=' sign. It says 'Expected then, got ='
local base = game.Workspace.WaitForChild("Elevatorbase")
local b2 = script.Parent
function two()
while true do
wait(0.01)
base.Position = base.Position+Vector3.new(0, 0.07, 0)
end
if
base.Position = -2.525, 16.18, -12.125
then
break
end
script.Parent.ClickDetector.MouseClick:Connect(two)

3 comments
change the = to ==, = assigns a value and == is checking the value against something(more or less)
At line 10 you got to use Vector3 so, base.Position = Vector3.new(-2.525, 16.18, -12.125)
im sure the if statement has to be inside the while true loop and change the equal sign on line 10 to > because if you just use a equal sign i could possibly go higher than that number and loop forever but the > sign will stop it if it goes above then it will stop and also change the value on line 10 to Vector3.new(-2.525, 16.18, -12.125)