Optimizing game

:warning: Only Developer Forum feature requests should be posted here.
Use #feature-requests for Roblox-related feature requests.

Be as specific as possible, give your post a clear and descriptive title, and focus on problems and use cases, rather than proposed solutions.


As a Roblox developer, it is currently too hard to …

If Roblox is able to address this issue, it would improve my experience using the forum because …


Hey devs i need optimizer a big map but i no have any idea how i make it, i tried put “StreamingEnabled”
but 2048 of Memory, is so much for Client mobile or bad pc user


how reduce usage of memory

The main ways are just streaming enabled (you can change teh settings of this so it can stream less if required - note that what you saw when testing may be different than what players on mobile will see), and just removing unneeded assets that aren’t shown to the player.

2 Likes

StreamingMode is removed because this game is for Cars

i tried use culling script but memory


800mb FREE

local RunService = game:GetService("RunService")
local CollectionService = game:GetService("CollectionService")

local details = {}
local lastCell = nil
local pendingUpdate = true
local updating = false

function AddDetail(instance)
	task.spawn(function()
		local record = {}
		record.cullDistance = 300
		record.instance = instance
		record.primaryPart = instance
		record.visible = true 
		record.parent = instance.Parent

		if (instance:IsA("Folder")) then
			while(true) do
				record.primaryPart = instance:FindFirstChildWhichIsA("BasePart", true)
				if (record.primaryPart == nil) then
					wait()
				else
					break
				end
			end
		end

		if (instance:IsA("Model")) then
			while(true) do
				record.primaryPart = instance.PrimaryPart or instance:FindFirstChildWhichIsA("BasePart", true)
				if (record.primaryPart == nil) then
					wait()
				else
					break
				end
			end
		end

		if (record.primaryPart == nil) then
			warn("Não foi possível encontrar uma parte principal para " .. instance.Name)
			return
		end

		local dist = record.instance:GetAttribute("distance")
		if (dist ~= nil) then
			record.cullDistance = dist
		end

		details[instance] = record
	end)
end

function Setup()
	CollectionService:GetInstanceAddedSignal("Detail_Small"):Connect(function(instance)
		AddDetail(instance)
	end)
	for key, instance in CollectionService:GetTagged("Detail_Small") do
		AddDetail(instance)
	end
end
Setup()

RunService.Heartbeat:Connect(function(dt)
	local player = game.Players.LocalPlayer
	local character = player.Character

	if (character == nil or character.PrimaryPart == nil) then
		return
	end

	local pos = character.PrimaryPart.Position
	local cellSize = 8
	local cell = pos // cellSize

	if (cell ~= lastCell) then
		lastCell = cell
		pendingUpdate = true
	end

	if (pendingUpdate == true and updating == false) then
		updating = true	
		pendingUpdate = false
		task.spawn(function()
			local counter = 0
			for instance, record in details do
				local vec = record.primaryPart.Position - pos
				local mag = vec.Magnitude

				if (mag < record.cullDistance and record.visible == false) then
					record.instance.Parent = record.parent
					record.visible = true
					-- Define transparência para 0 para torná-lo visível
					for _, part in pairs(record.instance:GetDescendants()) do
						if part:IsA("BasePart") then
							part.Transparency = 0
						end
					end
					continue
				end

				if (mag >= record.cullDistance and record.visible == true) then
					-- Define transparência para 1 para ocultar, mantendo CanCollide ativo
					for _, part in pairs(record.instance:GetDescendants()) do
						if part:IsA("BasePart") then
							part.Transparency = 1
						end
					end
					record.visible = false
				end

				counter += 1
				if (counter > 100) then
					wait()
					counter = 0
				end
			end
			updating = false
		end)
	end
end)

You should use content-streaming for big maps to help with poor CPU/GPU performance