print(newBrick.Material and newBrick.Name and newBrick.Color and newBrick.Size)
I want to print some properties of the new Instance, I made. But I get the error: "Material is not a valid member of Workspace "Workspace". I am very knew to programming and have no clue, what I made wrong. Here you can see the whole code it's about:
https://i.stack.imgur.com/3ZCY1.png
CodePudding user response:
This is not a syntax error. Your syntax is correct. You're indexing a table field that does not exist.
In line 15:
print(newBrick.Material and newBrick.Name and newBrick.Color and newBrick.Size)
you index newBrick.Material
but according to the error message Material
is not a valid member of Workspace.
newBrick
is the return value of CreatePart
. While you create it as a new Instance
in
local part = Instance.new("Part")
you assign part = game.workspace
right befor you return part
.
So instead of the Instance
you index game.workspace
with Material
.
You probably wanted to add game.workspace
as the parent of part
.
Otherwise I cannot make sense of your code.
So either use
local part = Instance.new("Part", game.workspace)
or
local part = Instance.new("Part")
part.Parent = game.workspace
Also what do you want to achieve with line 15? If you want to print several values use a comma, not and
. and
is for boolean logic.