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

Will this change make my code more efficient?

Asked by
AZDev 590 Moderation Voter
7 years ago

Alright. Some of you know I've been working on an FPS for some time now. My current system for swapping weapons destroys the current weapon and re-creates the new weapon every time the player swaps their weapon.

I'm not great at optimization but I did have an idea.

If instead of destroying and re-creating the weapons, I create all equipped weapons one time on startup (when the player spawns) and use nil as the parent of weapons not in use and then simply re-use those weapons, would I see any performance increase?

If I didn't explain this well enough, I'll gladly attempt to re-try explaining.

0
You could try, but remember to delete the weapons that are corresponding to that player once the player leaves the server... else there will be a lot of instances floating around not being used by anything. iiParadoxLegacy 38 — 7y
0
I'll be sure to make note of this. AZDev 590 — 7y

2 answers

Log in to vote
0
Answered by
Zeoic 40
7 years ago

You may get a very tiny performance increase, probably nothing notable. However, you would also have a slight memory increase keeping those tools around. Unless you have tons of weapons being switched between very often, I don't think either system would make much of a difference.

Ad
Log in to vote
0
Answered by 7 years ago

Considering the small amount of power ROBLOX requires to run, I highly doubt that would make a noticeable difference. However, it couldn't hurt to do that.

Answer this question