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

TweenSizeAndPosition doesn't work? (argument 2 missing or nil)

Asked by 4 years ago

So I made an image Button and whenever you click it a menu is supposed to pop up but I am getting an error saying (argument 2 missing or nill)

Here is my code

local menuButton = script.Parent
local mainMenu = script.Parent.Parent.MenuFrame.mainMenuFrame
local Tween = game:GetService("TweenService")

menuButton.MouseButton1Up:Connect(function()

    mainMenu:TweenSizeAndPosition{
        UDim2.new(0, 479,0, 271),
        UDim2.new(-7.792, 0,-0.742, 0),
        Enum.EasingStyle.Quint,
        Enum.EasingDirection.Out,
        1,
        false
        }



end)

Please tell me what I missed or what i'm doing wrong.

0
Don't use brackets, use parentheses. Just a tip, not sure if that'll fix it or not. But in my opinion I'd use parentheses. killerbrenden 1537 — 4y
0
I changed them to parentheses and got a new error "Unable to cast token to token". Btw I use parentheses for variables and other stuff and brackets for tables, in this case i'm listing multiple things so I used brackets for a table. Phase_Venom 55 — 4y

2 answers

Log in to vote
0
Answered by 4 years ago

So basically I had easing direction and easing style the wrong way around.

Easing Direction comes first then Easing style comes second.

I had Easing Style first and Easing Direction Second that's why it wasn't working, this is how it is supposed to look.

local menuButton = script.Parent
local mainMenu = script.Parent.Parent.MenuFrame.mainMenuFrame
local Tween = game:GetService("TweenService")

menuButton.MouseButton1Up:Connect(function()

    mainMenu:TweenSizeAndPosition{
        UDim2.new(0, 479,0, 271),
        UDim2.new(-7.792, 0,-0.742, 0),
        Enum.EasingDirection.Out,
        Enum.EasingStyle.Quint,
        1,
        false
        }



end)
Ad
Log in to vote
0
Answered by 4 years ago

So, first off, just like Killerbrenden said in his comment, you need to make the brackets parentheses. It's in a tween function, not a table, you're listing the information that the tween needs in order to fire, it's not a table. This is also why you got a different error when you changed them.

Now, for second error, all you need to do is switch the EasingStyle and EasingDirection. In TweenSizeAndPosition, EasingDirection comes first. I changed your code, and this is what it's like with the changes:

local menuButton = script.Parent
local mainMenu = script.Parent.Frame
local Tween = game:GetService("TweenService")

menuButton.MouseButton1Up:Connect(function()
    mainMenu:TweenSizeAndPosition(
        UDim2.new(0, 479,0, 271),
        UDim2.new(-7.792, 0,-0.742, 0),
        Enum.EasingDirection.Out,
        Enum.EasingStyle.Quint,
        1,
        false
    )
end)

Also, when I tested it, it made the frame go off screen, so you'll need to change where it moves to. It could just be my screen, but I'm not entirely sure.

0
Just refreshed the page after posting this answer, good work on finding it out yourself! kkkeelan999 92 — 4y

Answer this question