What do you want to achieve? So i made a gun system that appears to experience a lag spike every time someone gets killed or shoots alot. How can i “optimise” the scripts or have a way at reducing lag and making it smoother and faster?
What is the issue? Lag spikes and drop in performance when using guns.
What solutions have you tried so far? I have tried adding waits so it has a cooldown to make an attempt at reducing lag. I have Streaming Enabled turned on but im not sure if that changes anything.
EIDT: I’ve looked at the Performance stats in game and the game is using about 956 MB of memory, The ping is quite low at a base of 50. Does anyone know how i can reduce the memory used?
tbh is pretty impossible for a “big” game to use less than 700MB of memory independent of what you try, even when you make a game without anything it will use allot already over the “flag” that roblox has set which is 200MB
If you feel uncomfortable sharing it, you don’t need to. But additional info needs to be provided, such as when the lag occurs, whether it happens in general or when you do a specific thing like reloading. Other causes can be poor or unoptimized code.
I have stated that the lag occurs when using the gun in general or when u get a kill. I believe its because the code is not optimised as i have never learned how to optimise my code before. If you have any advice / help for me on how to optimise my code, could you let me know?
Well it would be better if you could pinpoint the code which is causing the lag by commenting certain parts of your code and seeing if the lag goes down, and if a culprit has been found, just post the code here
The gun is ran by 1 local script and 1 server script using FastCast in ServerStorage. My question is how by commenting does it make lag go down? I feel as though that would not fix anything.
I replaced all the Wait()s with “task.wait()” and deleted a dummy that lags when u kill it from the game and ive brought down the memory a bit and its freed up like 100+ MB
I have noticed that some people use a semi colon after a line for example
end;
-- or even,
end);
i was wondering if that means anything and if it affects the script in anyway?
You may want to check microprofiler for the reason of the huge latency between frames, it can help you identify whether it may be a physics issue ,or identify the group of scripts causing the issue.