Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

attempt to call a table value?

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

✓ Accepted answer

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

1 comment

0

Thx @cherrythetree

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

1 comment

0

Thx @Vathriel

This discussion is preserved as it was. New answers, comments, and votes are closed.