How do I fix these enormous lag spikes in my game?

What do you want to achieve? I want to stop my game from having lag spikes, it is a tycoon game.

What is the issue? The lag spikes affect me on a laptop so it would be very hard on moblie players and so far there are only a few droppers out of many.

What solutions have you tried so far? I was thinking about adding a setting to remove textures but other than that I want to know how to reduce these spikes.

Here’s a video of it down below:


I’m hoping that there’s a way to fix this other than adding a whole bunch of settings options because that wouldn’t be too effective…

Edit: This game contains 0 blender assets and everything was made in roblox studio.

3 Likes

There is probably some kind of memory leak in your code somewhere, I can’t say much other than to simply try searching for problems in your code, maybe in the code for spawning the parts?

2 Likes

oh my gosh i tried playtesting my game it almost fried my laptop i am never doing that again until im sure of the problem

1 Like

Disable cast shadows for all the parts created from the droppers.

If you want to go further, disable CanTouch, and disable CanQuery. If you can, anchor the parts that aren’t moving on the conveyor to reduce physics calculations.

I’m a scripter, and one time I was doing simple models that included small parts. I try testing and the default loading screen took 20 seconds and I only had less than 30 fps. Once I turned cast shadow off, things got better.

2 Likes

Do you have unions in your game?

1 Like

The game is a classic-style game with studs, and for some reason the reSurface tool AND building tools by f3x are unable to texture unions into studs I was thinking about unioning the parts but if I did that it would generally ruin the style of the game…

1 Like

Physics should be not that lag as much

it could be some script

try disable touch convenyour also add another collisiongroup as “Cube” it’s should be not being impact each other cube if you turn off collisiongroup again cube only

3 Likes

Alright time to test it prays that laptop survives

2 Likes

There are still some lag spikes but it’s much better than last time, last time it was so laggy I had to not only force quit roblox studio but restart my computer (It’s a laptop). Now, I can normally leave the game and it takes a sec or two but none of that quit application stuff

1 Like

maybe which script you are using for loop? only dropper right?
Convenyour just use once trigger

1 Like

Can you explain it better?

Maybe you’re doing Instance.new() like 15 parts in a second.

Maybe you can queue some of those stud like parts in ReplicatedStorage. And then just parten them to workspace or in the right location and position. That way, you can split and spread out the part-creation workload.

2 Likes

I put them in serverStorage, clone them, and then position them to the dropper’s “Dropper” part

2 Likes

Yeah the droppers use many while loops but I don’t necessarily know an alternative

2 Likes

Good catch, @Pish85 try to combine some scripts too. While it is easy to do, having too many scripts will cause lag. Try to only use 1 script to control the simulator system instead of 1 script per item in your simulator.

2 Likes

That’s a great idea! What’s better is that every dropper (At least on this part of the tycoon) has the exact same drop rate!

1 Like

Instead of doing explorer like this

DROPPER1
    Script
DROPPER2
    Script
DROPPER3
    Script

Do this:

Script -- Dropper handler
Folder
    DROPPER1
    DROPPER2
    DROPPER3

OH YEAH I JUST REMEMBERED: So basically each dropper has a script. There’s a plot called template plot. When you buy the button it clones the item from template plot to your plot and loops through the descendants and enables all scripts. Scripts in template plot are naturally disabled. If I had 1 script for every dropper I would have to mess around with properties and attributes and whatnot which could easily mess up my entire script

Welcome to software development!

I usually take commissions like this and do it very well. Not taking commissions though, because busy… oof

A way to fix the lag spikes that seem to be coming from the droppers is surely to disable the cast shadows from the parts that are spawned from the blocks.

Seems like you’re making a tycoon, instead of spawning many blocks with each different small amount, it’s better to merge them and spawn fewer parts but with a higher value.

I know it might be less visually appealing but it might improve the lag.

Checking for scripts that might cause this lag is also a solution.

1 Like

First method ( simple way )
Try this only single loop
you only need add IntValue to Dropper as delay and delaystart
also you can right? like a Parent dropper to new folder called “Dropper_loop”

while wait(1)do
for i,v in pairs(workspace.Dropper_loop:getChildren()) do
v.delay.Value=-1 -- keep dept per second
if v.delay.Value==0 then -- once delay reach 0
v.delay.Value=v.delaystart -- let just say edit this as 5 soo it mean it take 5 sec to able spawn then return to 5 sec again to be wait
print('add here to spawn stuff')
end
end
end