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)
Something like this should work:
until Frame.Position.X == 0.4 and Frame.Position.Y >= 0.4