function onClick() if script.Parent.Frame.Visible == false then script.Parent.Frame.Visible = true script.Parent.Frame.Position = UDim2.new(0,0,0,0) else script.Parent.Frame.Visible = false end end script.Parent.MouseButton1Click:connect(onClick)
How can I get this so that when the button is clicked, the frame moves from on spot to a new spot, smoothly?
I'd suggest using the TweenPosition method on the Frame
.
function onClick() if script.Parent.Frame.Visible == false then script.Parent.Frame.Visible = true script.Parent.Frame:TweenPosition(UDim2.new(0, 0, 0, 0)) -- There are more options for this method, if you want to read more about them check the wiki page. else script.Parent.Frame.Visible = false end end script.Parent.MouseButton1Click:connect(onClick)
Alright well what you would need to do is something called "Tweening" which comes from the word Inbetweening. It makes your GUI''s move.
It's quite simple
function onClick() script.Parent.Frame:TweenPosition(UDim2.new(0.5,0,0.5,0),"Out","Quad",5,"false",nil) end script.Parent.Frame.TextButton.MouseButton1Click:connect(onClick)
Instead of ( script.Parent.Frame.Position = UDim2.new(0,0,0,0)) you use (script.Parent.Frame:TweenPosition(UDim2.new(0.5,0,0.5,0),"Out","Quad",5,"false",nil))
there are six arguments in tweening.
-UDim is basically a Vector3 for the GUI's -"out" is the direction -"quad" is the style -"5" is the float time or how long it takes -"false" is overide and -nil is callback
To better understand it you can check it out on the Roblox Wiki:
u mean slow or real fast as if it Teleported?