Still have questions? Join our Discord server and get real time help.
Log in to vote

Tweening GUI size when Start GUI is clicked?

Asked by 4 months ago

So basically what i am trying to do is make it so that when you click on the start button when you join the game a black square will grow to cover the screen then shrink back down. Problem is that i can't figure out how to do said thing

local GUI = script.Parent
local Frame = script.Parent.Parent
local tran = script.Parent.Parent.Parent.Transition.Frame

function onClick()
tran:TweenSize(100, 0,100, 0), "out", 1)
Frame.Enabled = false
tran:TweenSize(0, 0,0, 0), "out"1)

thats all i have gotten

1 answer

Log in to vote
Answered by
Y_VRN 106
4 months ago

You're using the TweenSize function wrong. The syntax is:

guiobject:TweenSize(, OffsetX, ScaleY, OffsetY), easingDirection, easingStyle, time, override, callback)


  • UDim2 is a type of coordinate for UI developing. More on

    • ScaleX, and ScaleY are 0-1 values that depends on their parent's size (or the screen size if it does not have a parent). They represent width and height (multiplied by parent or window size) respectively.

    • OffsetX, and OffsetY are number values that nudges the object by pixels. They also represent width and height respectively but unlike Scale values they don't depend on screen size or parent size.

  • easingDirection is an enum for animation direction. Default is Enum.EasingDirection.Out

  • easingStyle is an enum for animation style. Default is Enum.EasingStyle.Quad

  • time defines animation duration

  • override allows for replacing an on-going animation applied to the object

  • callback allows for functions to be run after the animation


-- Pretend this script is inside a gui.
local testbox ='Frame', <the gui>)

testbox:TweenSize(,0,1,0), Enum.EasingDirection.InOut, Enum.EasingStyle.Quad, 5, false) -- fills the whole screen for 5 seconds.

You can approve this if it helped you.

You're welcome.

It worked but now it's giving me an error saying that my transition does not exist. Anyways thank you so much SpeedyGeckoYT 29 — 4mo
You're weclome. What was about the transition not existing? Can you provide us part of your code that was causing the problem? Y_VRN 106 — 4mo
I Fixed that but now i got "Unable to cast string to token" SpeedyGeckoYT 29 — 4mo
Oh yea on line 6 which is "tran:TweenSize(, 0,100, 0), "out", 1)" SpeedyGeckoYT 29 — 4mo
View all comments (4 more)
I recommend setting the parameter for easingDirection as an Enum (Enum.EasingDirection.Out), and that ROBLOX Studio thinks you put a number in the esaingStyle parameter. It should be, 0, 1, 0) , Enum.EasingDirection.Out, Enum.EasingStyle.Quad, 1). Y_VRN 106 — 4mo
By the way,, 0, 100, 0) is incorrect if you want your object to be only 100x100 pixels because it's in the Scale parameters. If you want it to consume 1/4 of the screen, do,0,0.5,0), or if you want to fill...,0,1,0) or 200 pixels wide, 300 pixles high..., 200, 0, 300). Y_VRN 106 — 4mo
YES THANK YOU! Now I just need to edit the frame and i'm done :D SpeedyGeckoYT 29 — 4mo
You're welcome. I'm glad I helped you. :) Y_VRN 106 — 4mo

Answer this question