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

How do you animate a GUI to 'slide' off of, and onto the screen?

What i'm trying to do is nothing fancy, but uses UDim2's which i am not familiar with. What i am attemping to do is just have my GUI slide off the screen, and back to it's original place when triggered by the press of a button. Here's all my code so far, because i'm not sure what y'all might need.

--RapperdoesMC
--[[Random stuff]]--
--{0, 1550},{0, 600} -closed
--{0, 1417},{0, 600} -open
--[[Variables]]--
open = nil;
togBut = script.Parent.Frame.ToggleButton;
fra = script.Parent.Frame;
this = script;
closedPos = {0, 1550},{0, 600}
openPos = {0, 1417},{0, 600}
--[[Functions]]--
function toggleMenu()
	print('Toggle pressed!');
	if open == true then
		--Close the menu, because it is open.
	else
		--Open the menu, because it is closed.
	end;
end;

script.Parent.Frame.ToggleButton.MouseButton1Down:connect(toggleMenu)

1 answer

✓ Accepted answer

What you're looking for is called Tweening!

--RapperdoesMC
--[[Random stuff]]--

--{0, 1550},{0, 600} -closed
--{0, 1417},{0, 600} -open
--[[Variables]]--

open = false;
togBut = script.Parent.Frame.ToggleButton;
fra = script.Parent.Frame;
this = script; --why?
closedPos = UDim2.new(0, 1550,0 , 600)
openPos = UDim2.new(0, 1417, 0, 600)
--[[Functions]]--

function toggleMenu()
	print('Toggle pressed!');
	open = not open
	fra:TweenPosition(open and openPos or closedPos, Enum.EasingDirection.Out, Enum.EasingStyle.Quad, 1, true)
end;

script.Parent.Frame.ToggleButton.MouseButton1Down:connect(toggleMenu)


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