Hello. I am having issues with lag in my game. Particularly a certain map that I have. I checked the microprofiler and it doesn’t seem too good. I was wondering how I can fix this problem because when I play in studio and live game, it seems to lag sort of bad and it can be really irritating. I am unsure if this is just maybe my wifi or if it is related to the map/game.
Right now what I think the issues might be but are not certain to be is the crowd movements and the plates located in the center of the map.
For the crowd: I have 36 models grouped into one big model. Within those 36 models are 36 parts.
There is a script named “Distributor” that gathers up the individual part in each model and clones a script into them that allows the part to move. That script looks like so:
wait(math.random(math.random(0.2,0.6),math.random(4,8))) --Breathe.
local Part = script.Parent
local distance = math.random(10,45) --The distance to move along the axis
local startingPos = Part.Position
while true do
Part.Position = startingPos --Just in case it messese up.
--Move upward:
for i = 1, distance do -- i represents the index or current position of the loop, it starts at one and goes to whatever the times to run is, meaning it will run that many times
wait(0) -- Wait for the designated speed time
Part.CFrame = Part.CFrame + Vector3.new(0, 0.1, 0) -- Change the CFrame by 0.1 to allow for a smooth transition
end
wait(math.random(0.2,0.8))
--Move downward:
for i = 1, distance do -- i represents the index or current position of the loop, it starts at one and goes to whatever the times to run is, meaning it will run that many times
wait(0) -- Wait for the designated speed time
Part.CFrame = Part.CFrame - Vector3.new(0, 0.1, 0) -- Change the CFrame by 0.1 to allow for a smooth transition
end
wait(math.random(0.2,0.8))
end
for the center plates: I have 5 models grouped into one big model. Within those 5 models are 113 models that contain some 4-6 parts each.
There is another script named “Distributor” that gathers up each primary part of the 113 models and clones a script into that. The script that is cloned has a TouchedEvent inside of it so that when the players touch the pad, the color will change.
When I test this in live game and studio, it seems to lag and never seems to be running smoothly as I would like it too. Could I possibly get some help to figure out why this is happening? Is it related to my part count? Should I cancel cloning a script into EACH part and instead just make it into 1 script for all? I am unsure how to go about this problem. I simply want to fix the lag issue here.