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

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

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

Something like this should work:

until Frame.Position.X == 0.4 and Frame.Position.Y >= 0.4

2 comments

0

It errors out

0

Could I have some more details, like what the error shown in the Output is please?

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