Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

How to make frames move across the screen?

Asked by 10 years ago
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

Log in to vote
1
Answered by
Ekkoh 635 Moderation Voter
10 years ago

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)
Ad
Log in to vote
1
Answered by
haillin 60
10 years ago

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

0
does notin. NinjoOnline 1146 — 10y
Log in to vote
-1
Answered by
KAAK82 16
10 years ago

u mean slow or real fast as if it Teleported?

0
slow, so its smooth, like when you click the button the frame will gradually move down NinjoOnline 1146 — 10y
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... KAAK82 16 — 10y
0
That'd be a terrible way to do it... Ekkoh 635 — 10y
0
lol I know KAAK82 16 — 10y

Answer this question