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

I'm... super bad at tweening, so I keep messing up with this tween?

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

1 answer

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)

3 comments

0

Trying it out rn! If it works I'll accept the answer, thanks for the help!

0

Cant seem to get this to work oof...

0

Are you 300% sure? I tried this myself and it seems to work wonders.

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