New: Nitro Boost our Discord server and receive full donation perks here on the website! Join the Scripting Helpers Discord Server to learn more! You can also Support on Patreon as always.
Still have questions? Join our Discord server and get real time help.
0

# Tweening GUI size when Start GUI is clicked?

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
wait(1.5)
tran:TweenSize(0, 0,0, 0), "out"1)
end
GUI.MouseButton1Down:Connect(onClick)


thats all i have gotten

1
Y_VRN 76
11 days ago

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

guiobject:TweenSize(UDim2.new(ScaleX, OffsetX, ScaleY, OffsetY), easingDirection, easingStyle, time, override, callback)

Whereas..

• UDim2 is a type of coordinate for UI developing. More on https://developer.roblox.com/en-us/api-reference/datatype/UDim2

• 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

Example:

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

testbox:TweenSize(UDim2.new(1,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.

0
It worked but now it's giving me an error saying that my transition does not exist. Anyways thank you so much SpeedyGeckoYT 29 — 11d
0
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 76 — 11d
0
I Fixed that but now i got "Unable to cast string to token" SpeedyGeckoYT 29 — 11d
0
Oh yea on line 6 which is "tran:TweenSize(UDim2.new(100, 0,100, 0), "out", 1)" SpeedyGeckoYT 29 — 11d