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

Part won't stop moving despite Repeat Until?

Hi, I made a script to resize a part and move another part, the problem I'm having is the part won't stop moving even though I've coded it to stop when the Position is at a certain Position, and yet the part still carries on Moving even after it's reached the position.

Here is the script:

local MDoor = script.Parent
local handle = script.Parent.Parent.Handle
game.Players.PlayerAdded:connect(function(player)
    player.Chatted:connect(function(msg)
        if msg == "Open Door" then
            repeat
            	MDoor:Resize(Enum.NormalId.Bottom,- 0.5)
            	wait(0.2)
            until MDoor.Size.y <= 1
        end
	repeat
		wait(0.2)	
		handle.Position = handle.Position + Vector3.new(0, 0.7, 0)
	until handle.Position.y == 17
    end)
end)

I tried using "MoveTo" but it didn't seem to work.

Any sort of help is greatly appreciated, Thanks.

2 comments

2

.7 doesn't go into 17 evenly, which means it'll never reach 17 exactly, it'll surpass it.

0

Thanks, That was a very dumb mistake on my part.

1 answer

✓ Accepted answer

You are increasing the position by 0.7 and that won't evenly add up to 17. Instead adjust it so it's more even or use

until handle.Position.y >= 17

Which means stop if it's position is equal to or greater than 17.

1 comment

1

Thanks, That was a very dumb mistake on my part

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