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:
01 | function module.create_app(parent) |
02 | local main_frame = Instance.new( 'Frame' ) |
03 | local top_frame = Instance.new( 'Frame' ) |
04 |
05 |
06 | main_frame.Parent = parent |
07 | main_frame.Size = UDim 2 ( 0 , 1084 , 0 , 673 ) --I get my error on this. |
08 | main_frame.Position = UDim 2 ( 0.5 , - 50 , 0.5 , - 50 ) |
09 |
10 |
11 | top_frame.Parent = main_frame |
12 | top_frame.Size = UDim 2 ( 0 , 1009 , 0 , 28 ) |
13 | top_frame.Position = UDim 2 ( 0.5 , - 50 , 0 , 0 ) |
14 |
15 |
16 | return (main_frame) |
17 | end |
It's a very simple error. You are trying to call UDim2 which is a table, replace it with UDim2.new
01 | function module.create_app(parent) |
02 | local main_frame = Instance.new( "Frame" ) |
03 | local top_frame = Instance.new( "Frame" ) |
04 |
05 | main_frame.Size = UDim 2. new( 0 , 1084 , 0 , 673 ) |
06 | main_frame.Position = UDim 2. new( 0.5 , - 50 , 0.5 , - 50 ) |
07 | main_frame.Parent = parent |
08 |
09 |
10 | top_frame.Size = UDim 2. new( 0 , 1009 , 0 , 28 ) |
11 | top_frame.Position = UDim 2. new( 0.5 , - 50 , 0 , 0 ) |
12 | top_frame.Parent = main_frame |
13 |
14 | return main_frame |
15 | end |
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:
1 | main_frame.Size = UDim 2. new( 0 , 1084 , 0 , 673 ) |
Which as you may know already is similar to Color3.new and Vector3.new
Hope that helps, Vathriel