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

Tweening GUI size when Start GUI is clicked?

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

thats all i have gotten

1 answer

Log in to vote
1
Answered by
Y_VRN 246 Moderation Voter
4 years 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 DraconianSG 58 — 4y
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 246 — 4y
0
I Fixed that but now i got "Unable to cast string to token" DraconianSG 58 — 4y
0
Oh yea on line 6 which is "tran:TweenSize(UDim2.new(100, 0,100, 0), "out", 1)" DraconianSG 58 — 4y
View all comments (4 more)
0
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 UDim2.new(1, 0, 1, 0) , Enum.EasingDirection.Out, Enum.EasingStyle.Quad, 1). Y_VRN 246 — 4y
0
By the way, UDim2.new(100, 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 UDim2.new(0.5,0,0.5,0), or if you want to fill... UDim2.new(1,0,1,0) or 200 pixels wide, 300 pixles high... UDim2.new(0, 200, 0, 300). Y_VRN 246 — 4y
0
YES THANK YOU! Now I just need to edit the frame and i'm done :D DraconianSG 58 — 4y
0
You're welcome. I'm glad I helped you. :) Y_VRN 246 — 4y
Ad

Answer this question