I’m currently learning about parameters & arguments in a function, could anybody direct me on what I did wrong while the parts are not spawning in while I run the game.
To help us help you, it’s also important to provide your code as text as opposed to a screenshot. Additionally, output messages or errors that the code generates in the Output window could tell what’s happening.
I haven’t received any errors in the output messages for some weird reason, the parts won’t just spawn in, could it possibly be the reason that the script was misplaced?
Where is the script? Can you show us the explorer?
I’ve located it and I did accidently place it in “Server Storage” and not “ServerScriptService”
The brick is completely spawning in now, but the properties are not applying, and a second brick is not being placed into the map.
This is the current output
Change your function to this:
local function Generatepart(name, IsAnchored, Reflectance, Color)
local part = Instance.new("Part")
part.BrickColor = BrickColor.new(Color)
part.Reflectance = Reflectance
part.Anchored = IsAnchored
part.Name = name
part.Parent = workspace
end
The reason why it’s erroring is because you have to use BrickColor.new
, also you have a few unnecessary parenthesis and using ("name")
will set both part names to "name"
and not the actual argument passed
-
It’s bad practice to set the parent of a new instance directly, you should alter the properties and then parent it to
workspace
. -
Putting a parenthesis around the parameter when assigning it to something is redundant, you shouldn’t do it.
-
It’s better practice to use local functions wherever you can.
-
The property is
Name
and notname
, it’s case sensitive. -
The
BrickColor
property only acceptsBrickColor
datatypes. -
When asking for help, provide the code (not through screenshots), give some context, and state what error pop ups, if there are any.