So I made a function that allows me to make GuiButtons,this function has five arguments:
.Size
.Position
.ButtonSize
.ButtonPositon
.PlayerImage
.Parent
but when I put them in I get an error saying:
Workspace.Script:35: ')' expected near ','
How would I add a UDim value you to this argument?
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(Objects,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(Objects,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(Objects,PlayerImage) ----------------------Returninig---------------------- return(Objects) end Button = CreateButton( UDim2.new(0.2,0,0.14, 0), UDim2.new(0.02, 0,0.02, 0), UDim2.new(0.2, 0,0.14, 0), UDim2.new(0.08, 0,0.13, 0), "http://www.roblox.com/asset/?id=133035324", game.Players.Player.PlayerGui.ScreenGui) --[[UDim2.new(0.2,0,0.14, 0), - Size UDim2.new(0.02, 0,0.02, 0)- Position UDim2.new(0.2, 0,0.14, 0) -ButtonSize UDim2.new(0.08, 0,0.13, 0)- ButtonPosition http://www.roblox.com/asset/?id=133035324"-Player Image game.Players.Player.PlayerGui.ScreenGui-Parent --]] for i,v in pairs (Button) do print(v) end
Sizes and Positions are UDim2
values.
You have to actually make UDim2
values when you are passing them -- that isn't just something like (1, 2)
(Lua doesn't allow this syntax -- because it wouldn't make sense -- which is what is causing your error)
So, something like this:
CreateButton( UDim2.new(0.2, 0, 0.14, 0), UDim2.new(0.02, 0, 0.02, 0), UDim2.new(0.2, 0, 0.14, 0), UDim2.new(0.08, 0, 0.13, 0), 0, game.Player.PlayerGui.ScreenGui )