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?
You didn't even make a table yet.
local guis = {} table.insert(guis,button) -- gg