Isn’t valid syntax - the interpretter thinks your until is for closing the while, as wait doesn’t create a new scope. If you want to wait for a property to reach a given value, you need to check it whenever it changes.
--Define a function that handles what to do whenever the position is changed.
local onPositionChanged = function()
if platform.Position == endPos then
BP.Position = endPos
elseif platform.Position == startPos then
BP.Position = startPos
--Run the function whenever the position of the platform changes.
As an aside, you can create a “wait until” if you have an event which fires whenever your condition is met, like this:
Though for your case there isn’t an event you can use for this, so you’ll need to use the method above.