You can check if the parent is nil
THANK YOU!
if all goes to plan⌠the lag problem may be solved
Playerâs also do not get properly destroyed on leave which is extremely bizarre and basically means every game using .PlayerAdded is leaking memory.
That canât be true right? Keeping players in memory after they leave would cause memory leaks whether the game uses PlayerAdded or not. I rely on garbage collection to automatically remove player data stored in a hashmap where the key is the player instance. Iâve never had issues with this, indicating the player is removed (at least at a high level I guess).
If having events bound to player instances causes issues with removing them I might have to start disconnecting all player events when they leave, which should already be handled by the engine. Iâll investigate it tomorrow and let you know what I find.
Sadly yeah, neither the Player nor its character gets destroyed.
When a player dies and you have connections made into any of the descendants of the character is better to disconnect all of it once it parents to nil or just destroy it manually (have in mind that you gotta check if the Humanoid is dead first as the character is parented to nil when CharacterAdded triggers). The same applies to the Player instance, they donât get destroyed and you have no permission to destroy it either.
I would appreciate it if Roblox had a function like DisconnectAll for a player at least, cuz else you will have to save all connections made into a table and iterate through it when they leave.
You gotta read all first:
When you create a new instance, it will be parented to nil and this doesnât mean is destroyed for example.
if instance then
ÂŻ_(ă)_/ÂŻ
Well I guess you could use attributes, but I get your point and it actually makes sense lol
I have not been having issues and I have it set to Default, but curious to know what this change would break.
This shouldnât break anything; it just calls Destroy
on an Instance on the client when itâs Destroyed on the server. Previously, it would just set its parent to nil
This post screams âinexperienced scripterâ
If anything, knowing about the ins and outs of the engine would make somebody a MORE experienced scripter
Can you explain this setting more?
When you call Destroy
on an Instance on the server, it will also call Destroy
on the Instance on client now instead of just setting its Parent to nil
. The setting was just around for anyone who relied on the old behavior of Destroy
not replicating
Why does it now replicate? It worked normally before
It works the exact same as before, except it properly locks the parent to nil
instead of just setting it nil
.
If anything, the update adds more consistency, since if you destroy something on the server, youâd expect for it to be destroyed on the client as well
Well, I would rely on it in certain circumstances, but not really.
Network Ownership. Clients must have network ownership over their character, including the instances inside their character. Now, I see your point with non-physics instances such as values. Still, ROBLOX has already made better alternatives for each of those things: The attributes I talked about earlier, and tables created on the server for folders/configs.
Using Folders/Configs to store player data is, IMO, a bad practice because it adds unnecessary instances and and possible event connections when you could use the better alternatives stated above.
they do have a DisconnectAll: All instances have it. When you :Destroy() an instance, it disconnects all connections as well, and calls Destroy on all the instances below it.
Now, if you want to disconnect all the instances without destroying it, you can just cache the connections in an array and go from there
Network Ownership is still needed in ROBLOX for physics. If you set the network owner of your character to the server, it manifests a massive input delay and a bad experience.
Also, .Destroying
does replicate
I didnât even know about that function! Hopefully it helps with lag when unloading maps for low power devices in my game!
You cannot destroy a player since you have no permission of doing so, Destroy is really different from a DisconnectAll function; even though the functionality of disconnecting everything from an Instance is included when you call Destroy. The error you get when calling Destroy on a player is âThe Parent property of Players.PlayerName is lockedâ. (@Khrrxs told me that you can destroy the player the next frame after PlayerRemoving triggers, which is a good thing to know)
This is why I literally said it will be useful to have DisconnectAll as a functionâŚ