This is a much-needed change, but it does break some behavior. I can think of several games that use corpses that despawn much later than the player respawns, and I believe the most seamless way to achieve the effect is to use method in the following pseudocode:
local Debris = game:GetService("Debris")
local Players = game:GetService("Players")
local player = players.Andy_Wirus --Server-sided
local character = player.Character
player.Character = nil
character.Parent = workspace
Debris:AddItem(character, 300)
task.wait(Players.RespawnTime)
player:LoadCharacter()
This code needs to reparent the character to work, because changing the Player.Character
reparents the old character to nil
with the old behavior, and calls Destroy
on it with the new behavior. Cloning the old character causes visible replication and physics lag, which isn’t present with the reparenting. I believe this is because the reparenting happens in one replication cycle, so the reparenting doesn’t actually take place on the client-side at all, and only the Character
property of the Player
changes. The change also breaks what I believe to be the only clean way to achieve the effect seen in Roblox’s body swap potion, which I have written psuedocode for below:
local Players = game:GetService("Players")
local player1 = Players.Player1
local player2 = Players.Player2
local character1 = player1.Character
local character2 = player2.Character
player1.Character = character2
player2.Character = character1
character1.Parent = workspace
character2.Parent = workspace
There needs to be a bypass in the function that calls Destroy
on the character to keep these scripts functional, and I believe that if it’s a use case interesting enough for Roblox to make a R$400 gear based on it, it’s not something that deserves to be affected by this change. I thought about requesting a new function to unlink the character from the Player
without destroying it, but I don’t think such a niche function would land very well with the team. Instead, I’d like to propose that characters with nil
Parent
s do not have Destroy
called on them when Player.Character
is changed. This way, I only have to add one line of code per character to keep the scripts functional:
local Debris = game:GetService("Debris")
local Players = game:GetService("Players")
local player = players.Andy_Wirus --Server-sided
local character = player.Character
character.Parent = nil --the new line of code
player.Character = nil
character.Parent = workspace
Debris:AddItem(character, 300)
task.wait(Players.RespawnTime)
player:LoadCharacter()
I do not believe this is a loophole that will cause any side effects in pre-existing games, and I hope this is a use case you will find as important as I do, @WheretIB.