So basically I'm trying to get the GUI to move to a certain position and STOP there, the gui just flies out of the screen and never returns... what am I doing wrong???? (My tween knowledge is nonexistent so I would really love an answer that explains the problem to me in detail)
local twen = game:GetService("TweenService") local ui = script.Parent local tweeninfo = TweenInfo.new( 2, Enum.EasingStyle.Linear, Enum.EasingDirection.In, 0, false ) local uiprop = { Size = UDim2.new({0.044, 0},{0.081, 0}); Position = UDim2.new({0.07, 0},{0.366, 0}); } local creation = twen:Create(ui,tweeninfo,uiprop) if ui.Visible == true then creation:Play() end
Use TweenSizeAndPosition on the frame, it's basically TweenService but easier.
Arguments:
Object:TweenSizeAndPosition(endSize, endPosition,EasingDirection.[In,InOut,Out], Enum.EasingStyle.[Linear, Sine, Back, Quad, Quart, Quint, Bounce, Elastic], tweenTimeLength, override, callback)
Usage:
script.Parent.Object:TweenSizeAndPosition(UDim2.new(0.5,0,0.5,0), UDim2.new(0.5,0,0.5,0), Enum.EasingDirection.InOut, Enum.EasingStyle.Quart, 1, true, function() print'finished tweening' end); --InOut back is broken. Don't use it lol
Oh yeah, by the way. Unpack your tables, UDim2 doesnt take tables. They take 2 sets of numbers.
Like so:
UDim2.new(0,0,0,0) UDim2.new(32,32,32,32) UDim2.new(0.7,2,0.3,4) UDim2.new(3,3,3,3)