so i have an instance that spawns without problems but i need to make it spawn with a name that isn’t “Part” how can i make it so it spawns with a custom name so i can use it in my code?
local Part = Instance.new("Part", workspace)
Part.Name = "somerandomnamelol"
Don’t use the second argument when you’re creating Instances.
I know I shouldn’t use a second argument on Instance.new() but that was just an example.
Why shouldn’t people use the second argument, isn’t it faster to have the Part spawn and just go straight to the workspace?
It has been tested by @LMH_Hutch and it showed that not using the second argument yielded a result that was ~133 times faster.
Edit: sorry I didn’t mean to reply to you
This is slow because it uses the parent argument of Instance.new()
.
I’m going to assume that he wants it to be named before it spawns, instead of parenting the part and then naming it (because the question says “spawn with a name”)
To do this, you can just set a property before you parent it. Then, when the part is parented, it will already have its properties set to what you want them to be.
local Part = Instance.new("Part")
Part.Name = "my name is part"
Part.Parent = workspace