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

repeat doesn't stop when the frame reaches its Until Position?

Asked by
Prioxis 673 Moderation Voter
10 years ago

I'm making a GUI that slides down when the key C is pressed but instead the menu drops down and doesn't stop

I know the issue is probably because its not hitting the exact UDim2 Position (0.4, 0, 0.4, 0) instead the second 4 is probably more like 0.41

If anyone could help figure out why it doesn't stop when it reaches its until that'd be great I've tried a few different things like changing the time and increase value but it still keeps moving and the animation isn't as smooth then

here's my script:

local Player = game.Players.LocalPlayer
local Mouse = Player:GetMouse()
local Frame = script.Parent.Main

function Open()
    print'opening'
    Frame.Visible = true
    repeat
        wait(0.1)
    Frame.Position = Frame.Position +UDim2.new(0, 0, 0.05, 0)
    until
    Frame.Position == UDim2.new(0.4, 0, 0.4, 0)
end

function Close()
    print'closing'
    Frame.Position = UDim2.new(0.4, 0, -0.4, 0)
    Frame.Visible = false
end

Mouse.KeyDown:connect(function(key)
if key == "c" then
if script.Parent.Main.Visible == true then
    Close()
else
    Open()
end
end
end)

1 answer

Log in to vote
0
Answered by 10 years ago

Something like this should work:

until Frame.Position.X == 0.4 and Frame.Position.Y >= 0.4
0
It errors out Prioxis 673 — 10y
0
Could I have some more details, like what the error shown in the Output is please? dudemanloserr 15 — 10y
Ad

Answer this question