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

Help with TweenPosition?

Asked by 8 years ago

I'm trying to understand TweenPosition, so I made a GUI, inserted a frame, and added this script into the textbutton of the frame.

local Button = script.Parent
Frame = script.Parent.Parent

Button.MouseButton1Click:connect(function(close)
    if Frame.Visible == true then
        Frame.TweenPosition = UDim2.new(0,100,0,300)
    end
end)

When I tried to execute it, the output tells me that TweenPosition isn't a valid member of the frame, could anyone explain to me what I'm doing wrong?

1 answer

Log in to vote
0
Answered by
Validark 1580 Snack Break Moderation Voter
8 years ago

TweenPosition is a function of GuiObject, not a property. Functions are executed like so:

Frame:FUNCTIONNAME(Parameters)

Also, you need to make sure to include all necessary parameters! Please reference the wiki.

local Button = script.Parent
Frame = script.Parent.Parent

Button.MouseButton1Click:connect(function(close)
    if Frame.Visible == true then
        Frame:TweenPosition(UDim2.new(0,100,0,300),"Out", "Quad", 1, true)
    end
end)

Edit "Quad" is the EasingStyle. The EasingStyle controls how fast it goes at any given point. The EasingStyle Linear makes it go the same pace the whole time, Sine starts fast and slows the closer it gets to the destination. Here are a bunch of graphs showing the equations for each combination of EasingStyle and "In", "Out", or "InOut".

The 1 is the float time, or in other words the amount of time it takes to Tween the object.

The last boolean at the end is for whether or not this tween can be interrupted by another Tween. Right now it is at true, so you could start another Tween on this frame and it would override the current one being run. If it was false, the new Tween wouldn't run.

0
Thank you, I referred to the Wiki after I posted this, and I was hoping for an explanation, but what you've given me is alright, I've figured it out now. Thank you for your time. Laserpenguin12 85 — 8y
0
If you have any questions about TweenPosition, I can answer them. Validark 1580 — 8y
0
There was one thing I couldn't find on the wiki, but why do you add "Quad, "1", true at the end? Laserpenguin12 85 — 8y
Ad

Answer this question