Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

My repeat until loop doesn't stop. I don't know why?

For some reason, this loop keeps going and the part keeps moving without stopping.

local p = script.Parent
wait(.1)
repeat
	wait(.1)
	p.Position = p.Position - Vector3.new(0, 1, 0)
until
	p.Position == Vector3.new(164, -5.8, -135.8)
	print'yes'

help ?!

1 comment

0

Edited to use Lua code formatting

1 answer

The problem is probably due to floating point errors. The part's Y position may not be exactly -5.8, and so the loop never ends. I'd use the >= operator instead.

local p = script.Parent 
wait(.1) 
repeat 
	wait(.1) 
	p.Position = p.Position - Vector3.new(0, 1, 0) 
until p.Position.Y >= -5.8
print'yes'

This discussion is preserved as it was. New answers, comments, and votes are closed.