Ad
Still have questions? Join our Discord server and get real time help.
Log in to vote
1

attempt to call a table value?

Asked by 3 days ago

I am trying to make a module that makes an instant New Frame but this is the error i get every single time i run my code: Workspace.ROS_API:55: attempt to call a table value

my code:

function module.create_app(parent)
    local main_frame = Instance.new('Frame')
    local top_frame = Instance.new('Frame')


    main_frame.Parent = parent
    main_frame.Size = UDim2(0, 1084,0, 673)--I get my error on this.
    main_frame.Position = UDim2(0.5, -50,0.5, -50)


    top_frame.Parent = main_frame
    top_frame.Size = UDim2(0, 1009,0, 28)
    top_frame.Position = UDim2(0.5, -50,0, 0)


    return(main_frame)
end

2 answers

Log in to vote
2
Answered by 3 days ago
Edited 3 days ago

It's a very simple error. You are trying to call UDim2 which is a table, replace it with UDim2.new

function module.create_app(parent)
    local main_frame = Instance.new("Frame")
    local top_frame = Instance.new("Frame")

    main_frame.Size = UDim2.new(0, 1084, 0, 673)
    main_frame.Position = UDim2.new(0.5, -50, 0.5, -50)
    main_frame.Parent = parent


    top_frame.Size = UDim2.new(0, 1009, 0, 28)
    top_frame.Position = UDim2.new(0.5, -50, 0, 0)
    top_frame.Parent = main_frame

    return main_frame
end
0
Thx @cherrythetree Retallack445 42 — 2d
Ad
Log in to vote
1
Answered by
Vathriel 477 Moderation Voter
3 days ago

You are calling UDim2 which is essentially a class in terms of OOP.

The method you are looking for is UDim2.new() which will allow you to construct an object of the type UDim2.

So it would instead look like:

main_frame.Size = UDim2.new(0, 1084,0, 673)

Which as you may know already is similar to Color3.new and Vector3.new

Hope that helps, Vathriel

0
Thx @Vathriel Retallack445 42 — 2d

Answer this question