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

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

Asked by 5 years ago

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

Log in to vote
0
Answered by
Fifkee 2017 Community Moderator Moderation Voter
5 years ago
Edited 5 years ago

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)
0
Trying it out rn! If it works I'll accept the answer, thanks for the help! Gomenasa1 32 — 5y
0
Cant seem to get this to work oof... Gomenasa1 32 — 5y
0
Are you 300% sure? I tried this myself and it seems to work wonders. Fifkee 2017 — 5y
Ad

Answer this question