'Unable to cast value to function'

Help me pls

print("1")

local OpenClose = script.Parent.MainFrame.OpenClose
local OnScreen = true

print("2")

OpenClose.MouseButton1Click:Connect(function()
    print("3")
    if OnScreen == true then
    script.Parent.MainFrame:TweenPosition(
        UDim2.new(-0.766, 0,0.269, 0),
        Enum.EasingDirection.Out,
        Enum.EasingStyle.Quad,
        1,
        true,
        false
        )
    else
        print("4")
    script.Parent.MainFrame:TweenPosition(
            UDim2.new(0.117, 0,0.269, 0),
        Enum.EasingDirection.Out,
        Enum.EasingStyle.Quad,
        1,
        true,
        false
        )
    end
    print("5")
end)

print("6")

the tween doesn’t work. It prints:
1
2
6

Click it, it prints: 3

then it errors with: Unable to cast value to function

(line 11)

You’re missing the last argument in your UDim2s.

Probably 0 in your case.

UDim2’s are constructed of 4 values: Scale X, Offset X, Scale Y, Offset Y.
Scale X is the size relative to its parent.
Offset is the absolute size in pixels, regardless of parent size. 100x100 would look bigger on a 500x500 screen than a 1000x1000 screen.

I have all 4 values though.
Value 1 is -0.766
Value 2 is 0
Value 3 is 0.269
Value 4 is 0

Didn’t see the second comma, sorry.

Could you point out which line is line 11?

Line 11 is

    script.Parent.MainFrame:TweenPosition(

The parameters are incorrect. You have UDim2, EasingDirection, EasingStyle, number, boolean, boolean
It should be UDim2, EasingDirection, EasingStyle, number, boolean, function (or nil)

-- example
GuiObject:TweenPosition(UDim2.new(0, 0, 0, 0), Enum.EasingDirection.In, Enum.EasingStyle.Linear, false, nil)