So I made a function that makes several Guis for me and and I got a error saying:
String expected
Script 'Workspace.Script', Line 22 - global CreateButton
Script 'Workspace.Script', Line 30
Why did I get this error if I'm giving a string by using the symbols ""?
How do I fix this error?
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
The code returned an error in the given area, because:
----------------------PlayerImage---------------------- local PlayerImage = Instance.new("ImageLabel",Parent) -- The second argument is the parent. It is giving the location of "ImageLabel". Perhaps change it to "script.Parent?" PlayerImage.BackgroundTransparency = 1 PlayerImage.Image = PlayerImage -- "PlayerImage" is an object. "Image" is a property of "PlayerImage." The "Image" property is meant to have a STRING value, not an OBJECT value. PlayerImage.Name = "PlayerImage" PlayerImage.Position = UDim2.new(Position) PlayerImage.Size = UDim2.new(Size) table.insert(Objects,PlayerImage)
Basically, you've made "PlayerImage" (Object) as the ID of the Image (String).
Image is an asset of ROBLOX's images, such as decals and textures. What the "Image" property should be is the URL (using "http://www.roblox.com/asset/?id=[ID]" or "rbxassetid://[ID]" (lol, you probably already know that).