Removing methods from an instance

  1. What do you want to achieve? Keep it simple and clear!
    Is there a way to remove a method of an instance (making it nil), or making it simpler in any way.

  2. What is the issue? Include screenshots / videos if possible!
    I have many projects where I use many parts or frames, such as a ray tracer, image loader, and world sim, however these all get really laggy.

  3. What solutions have you tried so far? Did you look for solutions on the Developer Hub?
    I removed material from the parts (smooth plastic), turned off collisions and made them anchored (and unions are out of the picture), and for the ray tracer and image loader I simply made the pixels less, which is not ideal.

This behavior, especially with the image loader confused me, because all I was doing were putting pixels up on the screen, so I thought it could be the many unneeded methods that each frame and part had, so I tried setting some methods to nil, which didn’t work.

So now I am wondering if there is a way to remove methods, or another way to reduce lag from unnecessary components of the instances.

2 Likes

There won’t be lag if an instance has a lot of methods. They are not directly attached to the instance. Instead, a metatable is attached which automatically knows what methods the instance should have. This is how OOP works to reduce memory! Therefore, you don’t need to remove methods to reduce lag. You can’t, anyways.

2 Likes

Is there any other way to “simplify” an instance, especially a frame, because I see no way why it should be so laggy.

1 Like

It depends on what your trying to do. If you have an image which is just a solid color with a corner, just use a frame with UICorner. If you have tons of frames making up a style, maybe use an image. You’d need to say what exactly your trying to make, and why it could be so laggy.

1 Like

I am making an image module, which allows someone to load an image (from its id), and allows filters to be used on it, so representing each pixel as a frame is important, however I can utilize UiGradients to represent 10 pixels.

This specific use case has been accomplished before, but in general, there is no way to remove methods of an instance.

You can, however, clear tables instead of deleting them, which may improve performance.

This is not the most performant solution. The least performance intensive material is actually Neon.

I suggest looking into the #help-and-feedback:code-review or #help-and-feedback category. Create a topic and ask for very specific performance enhancement advice according to your script (or code snippets).

1 Like

I implemented the neon material and already the performance was drastically better! Also I think the game looks much better with neon parts and darker Color3s. And I’ll start clearing tables in my games, thanks!

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.