Parts & Game Rendering Advice

  1. What do you want to achieve?

low lag for high part count map

  1. What is the issue?

lag

  1. What solutions have you tried so far?

deleting parts of my game… but I want to continue building.

so the gist is I made an Obby… has only 20 levels, but each are highly themed and not sure the exact part count but would assume somewhere in 50k or idk… it lags. I have a couple questions

  1. if I move the levels FAR apart could that reduce lag?
    and
  2. I also heard from friend and saw it in action on RHS there is some type of script/plugin that renders only an area around the character instead of the full map. Kind of like how Minecraft does it with chunks how can I achieve this?

please reach back! I love game devolvement and learning Lua has been a blast but I feel stuck. I don’t want to progress game anymore due to lag issues from trying to detail.

I cant guide you to the proper process… cause Im learning it right now…

I built a system that creates an infinite obby, I had no lag yet, but, I bet low devices does. So I need to understand how to render only part by part of the map.

https://developer.roblox.com/en-us/articles/content-streaming
https://developer.roblox.com/en-us/api-reference/property/Workspace/StreamingEnabled

Check that info, and tell me if you found the perfect way to handle this. Im working on it too.
Specially this I think should be done on our scripts before trying to accomplish the “chunk system”

image

You totally sure the parts are the problem? Maybe scripts too? First you should take count of ur parts in the map maybe.
Do a loop, checking if IsA “Part” “MeshPart” etc, and get an average of the parts in ur entire map.

EDIT: I forgot to add this topic, which is helpful:

1 Like

game only consist of a few scripts and maybe 1 or 2 loop.
and how would I set up a loop to check parts?

1 Like

Hiwi!

Well on RobloxHub theres examples, like this one:

I forgot about that GetDescendants() exists… (Im a shame…) and I built this simple and silly code too:

local numb = 0
local function seeker(x)
	for _, a in pairs(x:GetChildren()) do
		if a:IsA("Model") then
			seeker(a)
		end
		if a:IsA("Part") or a:IsA("MeshPart") then
			numb += 1
			print("Part ", numb, ": ", a)
		end
	end
end
seeker(game.Workspace)

Obviously using GetDesendants() makes MORE sense (as the robloxhub example), so, maybe if you want the Part count on your console, just add a counter var and print it:

local descendants = game.Workspace:GetDescendants()
local numb = 0
for index, descendant in pairs(descendants) do
	if descendant:IsA("BasePart") then
		numb += 1
		print(descendant, " ", numb)
	end
end

Both codes works, choose any you want to, no matter if your parts are inside models and models inside models, and more parts inside those models and etc etc etc…
I dont think theres a need for you to add this as a Script in your game. So just copy/paste and run the code on the CommandBar in your Roblox Studio, you’ll get the Total Count of Parts in the Output Console.

If you are using MeshParts, then change the code to fit ur requirements. I dont know the structure you use to build, so just experiment with the code and find your Total Parts Count.

EDIT (haha Im having different count part when I tested the codes. GetDesendants() is clearly the best way)

1 Like