Game lags when equipping a certain weapon

Hello! I have made an FPS Game, the only problem is, when I equip a certain weapon, the game just decides to lag, is it because of scripts or is it because of meshes?

Video demonstrating it, as you can see at the top, the whole game lags.

If someone knows what could cause this, please tell me, thanks!

1 Like

have you checked how many triangles your mesh takes up? a few thousand should be okay. it is most likely the scripts that make up the gun. look out for loops that go through very large tables or client scripts that run remote events or functions often. if you are comfortable, could you maybe show us your code?

1 Like

I don’t think it’s the code though, I checked how many triangles the mesh has 71 thousand triangles, is that too much?

Make sure you follow some of these steps


-task.Wait() - Changes the delay
-There should be no loops - It reduces the load on Roblox
-The number of events is limited - There are not too many events per minute
-Test on different pc
-Min. Animations per minute

I tried to list everything that came to my mind. Let me know if anything changes.

1 Like

yes. that is quite a bit. try simplifying the mesh a bit

I will try this!

asdadsddsadsdadawdwa

i managed to reduce the mesh to 30 thousand triangles!

good job! however, try and get it below 10,000. you should do much better at that point

I think around 20-30 thousand is good, since the g36 has that amount and it works just fine

Are there any effects? Is it still the same?

1 Like

I first tried @Chiseled_Cheese’s method, the game is still laggy, I will try to continue tommorow!

Okay, okay, okay… fosdjaasfjoasfmk

1 Like

it is still the best to try to tone it down to <10k. also, your scripts may have an issue if you are still experiencing lag

1 Like

I did actually tone the models near 10k, it seems that my script is not made well, I don’t know why though, as I’m using task.wait() and coroutine wrap so it doesn’t affect the whole script when a function has a waiting period.
Could this just be a Roblox issue?

hello, I managed to remake the script and it’s not laggy anymore, turns out i was firing too many events, most being in a loop

1 Like

i’m glad you figured out your issue! happy programming

1 Like