Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

Will this change make my code more efficient?

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.

2 comments

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.

0

I'll be sure to make note of this.

2 answers

✓ Accepted answer

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.

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.

This discussion is preserved as it was. New answers, comments, and votes are closed.