How to prevent my project from lagging

Hello. I’m a Lithuanian developer who joined on 4/13/2014
Currently, I am working on a new project where the players spawn in the first area. Every area has a unique map style, like medieval, modern or some kind of culture. Apparently I have made only 3 maps so far because I do every single step on creating a game by myself. My scripting skills are pretty decent but I am learning every once in a while more things to create something more well made and scripted. Every map has 20 boxes that every player could open to get a weapon and fight with others and as soon as you open a box the system that I scripted drops another box to keep the same amount of boxes on the map. Every single map has the same system which means that every single map has a script that runs the system I wrote. The player unlocks areas by killing people.

My main problem is, that I build everything for myself but I don’t really know what makes the game lag - heavy. I made 3 maps and its already heavy for the player who is playing on the mobile phone or console, or computer it doesn’t matter. As long as you turn your camera away from the side where is other maps are pretty fine with the lag, but once you turn your camera to further maps, it feels heavy. I can’t imagine playing on a mobile phone because it would be a terrible experience. I made walls, trees, a well, grass and other things with AUTODESK MAYA - meshes.

You can find this project here







Droping boxes script:
ss = game:GetService(“ServerStorage”)
–FOfD = ss:WaitForChild(“Weapons1”)
local MyTable = {}
MyTable[1] = ss:WaitForChild(“Weapons1”)
MyTable[2] = ss:WaitForChild(“Weapons2”)
MyTable[3] = ss:WaitForChild(“Weapons1”)
MyTable[4] = ss:WaitForChild(“Weapons2”)
MyTable[5] = ss:WaitForChild(“Weapons1”)
MyTable[6] = ss:WaitForChild(“Weapons2”)
MyTable[7] = ss:WaitForChild(“Weapons1”)
MyTable[8] = ss:WaitForChild(“Weapons2”)
MyTable[9] = ss:WaitForChild(“Weapons1”)
MyTable[10] = ss:WaitForChild(“Weapons2”)
MyTable[11] = ss:WaitForChild(“Weapons1”)
MyTable[12] = ss:WaitForChild(“Weapons2”)
MyTable[13] = ss:WaitForChild(“Weapons1”)
MyTable[14] = ss:WaitForChild(“Weapons2”)
MyTable[15] = ss:WaitForChild(“Weapons1”)
MyTable[16] = ss:WaitForChild(“Weapons2”)
MyTable[17] = ss:WaitForChild(“Weapons1”)
MyTable[18] = ss:WaitForChild(“Weapons2”)
MyTable[19] = ss:WaitForChild(“ChineseBox1”)
MyTable[20] = ss:WaitForChild(“Weapons2”)
BoxDrop = false

if BoxDrop == false then
BoxDrop = true
else
BoxDrop = false
end

while wait() do

if BoxDrop == true then
local drop = MyTable[math.random(1,20)]
wait(1)
local balldropheight = 20
local xPosition = math.random(-56, 133)
local zPosition = math.random(-140, 46)
local cloneofball = drop:Clone(game.Workspace)
cloneofball.Parent = game.Workspace:WaitForChild(“Arenas”).Creates.Area1
cloneofball.Position = Vector3.new(xPosition, balldropheight, zPosition)
wait()
end
if game:GetService(“ReplicatedStorage”):WaitForChild(“BoxCount1”).Value == 19 then
BoxDrop = false
else if game:GetService(“ReplicatedStorage”):WaitForChild(“BoxCount1”).Value < 20 then
BoxDrop = true
end
end
end

Let me know what makes the project be heavy/laggy, the main rules. Thank you

2 Likes

The game doesn’t seem to be particularly complicated building and scripting wise. What are your PC specifications? Maybe it isn’t strong enough to run your game smoothly?

2 Likes

Screenshot_2 Screenshot_1

It can be my computer?

2 Likes

Anything more than that? RAM’s also important here

2 Likes

Sorry. Everything is in my language i hope you will be fine with that.
Screenshot_4 Screenshot_3

2 Likes

I do believe that it’s your graphics card that is in the fault here. It’s a 2011 graphics card that’s integrated with your CPU. It’s not the best thing since it’s an old graphics card that still struggles with the problems most integrated cards have. I already looked up the specs for it and it has bad reviews in general. I do suggest getting a dedicated graphics card if you can.

4 Likes

I will do something about it. Thank you for yout time!

1 Like

I think the part makes it laggy because when the part is combined with under part it will make a little bit laggy but if you do it a lot of time it will get laggier when you wanna play or you wanna test

1 Like