Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

Part won't stop moving despite Repeat Until?

Asked by
KenzaXI 166
7 years ago
Edited by OldPalHappy 7 years ago

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
.7 doesn't go into 17 evenly, which means it'll never reach 17 exactly, it'll surpass it. Azarth 3141 — 7y
0
Thanks, That was a very dumb mistake on my part. KenzaXI 166 — 7y

1 answer

Log in to vote
1
Answered by 7 years ago

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
Thanks, That was a very dumb mistake on my part KenzaXI 166 — 7y
Ad

Answer this question