How to unload a character (and workspace) for a client?

Hi! I’m making a 2d-specific game where the player can go back into a 3d space for a hangout/flexing.
I’ve tried to look around for some stuff, but can’t find anything better than setting character to nil, which doesn’t unload workspace.

in short,

How do I unload the character and workspace?

I know how to do player:LoadCharacter(), but I’m lost as to how to unload workspace and the character when they decide to go back to 2d (for performance). How to?

What I’ve figured out so far, as mentioned earlier, is just:

player.Character = nil;
-- >> and...
player:LoadCharacter();

I’m so clueless how to effectively unload the character and workspace, hopefully without doing a lot of :Destroy()s. Anything would be nice.

For clarification, is there any built-in function or non-built in (module) function that could do this efficiently and effectively?

As far as I am not aware, I do not think there is a way to unload a character.

Something that would serve a similar function, though, would be to remove the character model from the workspace and then set the character to nil.

player.Character:Destroy()
player.Character = nil

This should remove the reference as well as the physical object from workspace. You should now be able to reload the character using player:LoadCharacter() fine as well.

Let me know if you need any more help!

Ah, unfortunate.

Would it be worthwhile to at least parent the map somewhere else? Or no?
Just want it to have okay performance

I have unloaded the workspace from the client by adjusting the focus area for the player’s CurrentCamera instance. This does not technically completely unload the workspace, but will prevent it from rendering on the client.

Does this answer your question sufficiently?

Yeah, I’d say so. Thanks!
so basically just change the focus (i’m assuming moving the camera in a way that doesn’t face towards whatever you need to be unrendered?)

Yep, exactly. Though, I haven’t experimented with this or if it changes once a new character loads - so just be careful.

I’d say thats a solution - I’ll mark it as a solution

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.