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

How to make frames move across the screen?

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?

3 answers

✓ Accepted answer

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:

http://wiki.roblox.com/index.php/Tweening

1 comment

0

does notin.

u mean slow or real fast as if it Teleported?

4 comments

0

slow, so its smooth, like when you click the button the frame will gradually move down

0

oh, I think u'd need loads of positions and wait()... so that its .position = bla. .wait(). and repeat but change position numbers... u get wat am saying...

0

That'd be a terrible way to do it...

0

lol I know

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