Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
1

Is it more efficient to instantiate objects in script or in Studio through Explorer?

Asked by
Irunui 15
7 years ago
Edited 7 years ago

I feel that the answer to the question would depend on the situation, but, I am hoping that someone can provide me (and others who may look at this question) a good explanation into efficient scripting.

Also, to clarify what I mean by "efficient", I mean it in many ways, but the primary standards being: -Hogging less resources -Runs faster with the least amount of function calls I mean, if I make stuff on the Explorer, it seems like I am putting in less lines of code, but because functions here are sometimes covered with syntactic sugar (and plus, I don't know how efficiently ROBLOX instantiates something already put into say, game.ReplicatedStorage), I really don't have a solid clue which one would be more efficient.

Here are two situations:

Would doing this in a Script...

local event = Instance.new("RemoteEvent", game.ReplicatedStorage)

...be more efficient than putting a RemoteEvent in ReplicatedStorage through the Explorer in Roblox Studio so that instead I can do...

local event = game.ReplicatedStorage.RemoteEvent

Or for instance, in a gun tool, would it be more efficient to instantiate a bullet in the script like...

local bullet= Instance.new('Part') do
bullet.Name = 'Rocket'
bullet.FormFactor = Enum.FormFactor.Custom 
bullet.Size = ROCKET_PART_SIZE
bullet.CanCollide = false

...or put in a bullet in the tool (or some other location) through the Explorer in Roblox Studio and make the local variable bullet reference like...

local bullet= script.Parent.bullet
1
Why on earth would one be more "efficient" than the other? Efficient in what way? BlueTaslem 18071 — 7y
0
My question: local bullet = Instance.new('Part') do -- Makes no sense to put 'do'. Vingam_Securis 213 — 7y
0
"local bullet = Instance.new('Part') do" is actually from UristMcSparks' rocket tool available from Free Models. And, knowing his scripting capabilities, I have no doubt that he had something in mind... Irunui 15 — 7y
0
@BlueTaslem, I'm sorry I wasn't very clear. I read my post again, and yes, it was a bit unclear. I edited it to explain what I meant by "efficient". Irunui 15 — 7y

1 answer

Log in to vote
0
Answered by
lukeb50 631 Moderation Voter
7 years ago

Making them using Explorer allows you to make them exactly as you wish without a lot of code. this is one this the wiki teaches you to do in the wrong way. take GUIs, it is allmost impossible to design one via script.

only use scripts when there are too many parts to create or there are too many possibilities that you would have to create 1 at a time.

0
Ah, thank you! Irunui 15 — 7y
Ad

Answer this question