"Unloading" assets depending on location

Hello, Im looking for scripting help.

Does anyone know how to go about accomplishing this. The map “unloads” depending on where you are. If you know how this is achieved or if its just a roblox thing please leave a reply.

My graphics are full and I have a medium range pc if that helps, thank you.

this forum should help you for this

I have two solutions, the logic is simple.
Step 1: Put every assets you want it to be unloaded and loaded in a special Folder, make sure it won’t broke every existing scripts.
Step 2: If the assets are models, you should set a Primary part, it’s very important for distance detection.
Step 3: Create a localscript

This script is not tested but it should work

local StoredModels = {}
local WorkspaceModels = workspace.Models

local Distance = 50

while wait(10) do
	for _,model in pairs({table.unpack(WorkspaceModels:GetChildren()), table.unpack(StoredModels)}) do
		if (workspace.CurrentCamera.CFrame.Position - model.PrimaryPart.Position).Magnitude >= Distance then -- If the camera is far from the model then
			if model.Parent then -- Get rid of the model and save it into a dictionnary to make sure we can get the model again
				model.Parent = nil
				table.insert(StoredModels, model)
			end
		else
			if not model.Parent then
				model.Parent = WorkspaceModels
				table.remove(StoredModels, table.find(StoredModels, model))
			end
		end
	end
end

Or use StreamingEnabled

7 Likes