I’m making a rooms game, and getting halfway through 1 section is horrible. At A-250 it starts to lag because 250 rooms are being rendered at once. Possibly over 60-100 parts each room. You can tell that that’s absolutely horrible. Is there a code that can make it so only parts in a certain distance are rendered?
(Only for the client)
Don’t know if this’ll work, but you could try grouping each room, and when the player is around 500 studs away you can set the room parent to nil on the client. Or if your game doesn’t allow the player to go backwards at all, then you can just use :Destroy().
The rooms are grouped as a model. Would I have to make a localscript in every room or a localscript for the player that checks every room?
It’s probably better to group all of the separate rooms and then detect how far away they are from there. And yes, would need a local script for the player that checks how far every room is. Or you could group sections of 5-10 rooms at once and once the player is far enough or gets out of that section, you can destroy it on the client, or set the parent to nil.
Well yes, all the seperate rooms are each grouped as a model.
Oh okay, then you can just set the primary part of all of those rooms to a random part and detect how far the player is away from the part.
If it were to be destroyed on the client, can the LocalScript still detect them? Because they can still go back. And setting the parent to “nil” means they won’t be in the workspace.Rooms folder anymore and I wouldn’t be able to check for them.
You can save the position of every room that was set to nil in a table.
Have you tried using StreamingEnabled?
I’ve never used that before.
(Character limit)
Try enabling it in workspace and set the StreamingTargetRadius and StreamingMinRadius to your desired amount; which I assume is 500 studs and StreamOutBehaviour to Opportunistic
See if that works
Okay, I’ll test it out. Thanks for telling me that because I actually didn’t know that even existed lol
I’m assuming everything went well?
Very well! Thanks! I’m glad I know about it now.
Outside of Roblox’s streaming service, you could do something simplistic such as getting the surrounding rooms of the current room you’re inside and unrendering (reparenting to replicated, or an algorithm that deconstructs/reconstructs the room) any room beyond that. Or go as far as the maximum rooms you want to have spawned at once. Similar to how Minecraft loads their chunks in, and all you’d have to do is keep note of which room/chunk they’re in.
There’re many ways of doing this spatial mapping as well for even more convenience.
To note, you could have the server contain all these rooms and parent them to replicated for the client to parent them to workspace. It would help lower the Memory for the client if it’s done like that, but it does come with the consequence of relying on the latency of the server → client or client → server → client (whichever way it’s done).
I didn’t mark your post as a solution because it happens to the entities too and ends up lagging the game terribly.
I have no idea how to do that.
Considering your entities are models, set the ModelStreamingMode to Persistent, which won’t stream them out.
The rooms are models, not the entities.
I ended up changing that.
I guess I can’t use StreamingEnabled then. Oh well.