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?
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.