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

"Attempt to call a UDim2 value" when trying to tween a gui?

Asked by 3 years ago
Edited 3 years ago

I have a GUI that I want to tween when a button is clicked, and I'm pretty sure I wrote it correctly because I compared it to another working tween script I have.

button.MouseButton1Up:Connect(function()
    if not selected then
        InventoryFrame:TweenPosition(
            UDim2.new(0.499, 0, 0.063, 0)
            "Out",
            "Quad",
            1,
            true
        )
        selected = true
    else
        InventoryFrame:TweenPosition(
            UDim2.new(1.2, 0, 0.063, 0),
            "Out",
            "Quad",
            1,
            true
        )
        selected = false
    end
end)

When I click the button I get an output saying Players.frogeater12345.PlayerGui.Hotbar.Hotbar.Inventory5.InventoryButtonScript:9: attempt to call a UDim2 value

0
You forgot a , on line 4. UDim2.new(0.499, 0, 0.063, 0) needs to be UDim2.new(0.499, 0, 0.063, 0), WizyTheNinja 834 — 3y
0
Thanks WizyTheNinja I didn't see that frogeater12345 -3 — 3y

1 answer

Log in to vote
0
Answered by
KixWater 126
3 years ago
Edited 3 years ago

Try this, instead of doing "if not selected then", try to remove those parts and don't do the else statement because it is like saying if I pressed it then the GUI stays the same or something like that, just make sure the GUI is off of the screen before you press the button the open the GUI.

For example, this is what I did for one of my GUI's:

local QuoteButton = script.Parent.MainMenu.QuoteoftheMonthButton
local quote = script.Parent.QuoteoftheMonth
local Exit = script.Parent.QuoteoftheMonth.ExitButton

QuoteButton.MouseButton1Click:Connect(function()
    local mouse = game.Players.LocalPlayer:GetMouse()
    script.Parent.Parent.Click:Play(mouse)
    quote:TweenPosition(
        UDim2.new(0.296, 0,0.103, 0),
        "Out",
        "Quart",
        1,
        false,
        nil
    )
end)

Exit.MouseButton1Click:Connect(function()
    local mouse = game.Players.LocalPlayer:GetMouse()
    script.Parent.Parent.Click:Play(mouse)
    quote:TweenPosition(
        UDim2.new(0.296, 0,-1, 0),
        "Out",
        "Quart",
        1,
        false,
        nil
    )
end)
0
For example this is what I did for mine: KixWater 126 — 3y
Ad

Answer this question