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

Help with adding UDim values to a table?

So I made a function that allows me to make GuiButtons,this function has five arguments:

**.**Size

**.**Position

**.**ButtonSize

**.**ButtonPositon

**.**PlayerImage

**.**Parent

However the size and position arguments will error on me if I try to add a UDim value to them. How will I add a UDim value to a table?

function CreateButton(Size,Position,ButtonSize,ButtonPosition,PlayerImage,Parent)
----------------------ObjectTable----------------------
local Objects = {}
----------------------Button----------------------
local Button = Instance.new("TextButton",Parent)
Button.Style = Enum.ButtonStyle.RobloxRoundButton
Button.Size = UDim2.new(ButtonSize)
Button.Text = "PlayerName"
Button.Name = "Button"
Button.Position = UDim2.new(ButtonPosition)
table.insert(Button)
----------------------ButtonUnderImage----------------------
local Buttonunderimage = Instance.new("Frame",Parent)
Buttonunderimage.Style = Enum.FrameStyle.DropShadow
Buttonunderimage.Size = UDim2.new(Size)
Buttonunderimage.Name = "ButtonUnderImage"
Buttonunderimage.Position = UDim2.new(Position)
table.insert(Buttonunderimage)
----------------------PlayerImage----------------------
local PlayerImage = Instance.new("ImageLabel",Parent)
PlayerImage.BackgroundTransparency = 1
PlayerImage.Image = PlayerImage
PlayerImage.Name = "PlayerImage"
PlayerImage.Position = UDim2.new(Position)
PlayerImage.Size = UDim2.new(Size)
table.insert(PlayerImage)
----------------------Returninig----------------------
return(Objects)
end

Button = CreateButton()
for i,v in pairs (Button) do
	print(v)
end

Oh,How would I add a instance to a table because I tried adding a instance using table.insert() and I got an error saying:

Workspace.ButtonCreator:11: bad argument #1 to 'insert' (table expected, got userdata)

How would I do it?

1 answer

You didn't even make a table yet.

local guis = {}
table.insert(guis,button) -- gg

1 comment

0

I know that but if I do I will get an error

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