Without having to clone the character’s dead body, is there a way to stop a player’s character being removed when they respawn?
From what I looked into so far, the answer seems to be no.
Without having to clone the character’s dead body, is there a way to stop a player’s character being removed when they respawn?
From what I looked into so far, the answer seems to be no.
Could you disable the Humanoid dead state, then check when the player would have died?
You could do this, check the health of the characters humanoid everytime it changes and then transfer the character to a spawn point and whatnot.
Can you try setting the Player’s character to nil (as in, Player.Character = nil
) before respawning them?
EDIT: Doesn’t work.
EDIT: Okay, before setting the .Character
to nil
, store it in a variable. After setting .Character
to nil, reparent the old character to workspace.
local LocalPlayer = game.Players.LocalPlayer
local OldCharacter = LocalPlayer.Character
LocalPlayer.Character = nil
OldCharacter.Parent = workspace
-- You have to manually respawn the character afterwards.
LocalPlayer:LoadCharacter()
EDIT, again: You don’t even have to set .Character
to nil. Just re-parenting the old character to workspace after the old character disappears works.
look at me im 3 years late ee but believe it or not there actually is and always been i’m replying to this cuz it seems to pop up whenever you look for the answer on search engines.
You see roblox’s respawn triggers when the humanoid reports as dead so if you prevent the player from dying it’ll never respawn an easy way of doing that is this:
OgChar = Player.Character
OgChar.Archivable = true --otherwise roblox deletes it to save memory whenever you parent it to nil
OgChar.Parent = nil
Player:LoadCharacter()
owner.CharacterAdded:Connect(function(Added)
if Added ~= OgChar then
owner.Character = OgChar
Added:Destroy()
end
end)
^that keeps a copy of your character in nil so if you die your character gets set to the nil parented character which is good enough to convince roblox that you never died HOWEVER BE CAREFUL!!!
If you’re going to use this for a serious game since you turn on the anti spawn character’s archivable on it can cause MEMORY LEAKS so you better keep track of all the anti spawn characters on a dictionary and destroy/add them as players leave/join yes ik this is a weird solution but it works sorry for being 3 years late at least ppl looking for this question’s answer now wont be left alone in the dark wondering around for an answer for hours and will know that it is possible even tho not very efficient!
im sorry but this solution doesn’t work
setting it nil will automatically destroy it
There is no way without cloning.
This is a bit of a rough draft way to do this, but you could…
then in server scripts…
game.Players.PlayerAdded:Connect(function(player)
player.CharacterAdded:Connect(function(character)
character:WaitForChild("Humanoid").Died:Connect(function()
character.Head.CanCollide = true
wait(3)
character.Archivable = true
local deadChar = character:Clone()
deadChar.Name = "DeadChar"
character:Destroy()
deadChar.Humanoid:Destroy()
deadChar.HumanoidRootPart:Destroy()
for _,i in pairs(deadChar:GetDescendants()) do
if i:IsA("Motor6D") then i:Destroy() end
end
deadChar.Parent = workspace
player:LoadCharacter()
end)
end)
player:LoadCharacter()
end)
oh wait, i’ve found an easier way
basically just create a new model and insert everything from the character (except the humanoid root part)
local character = script.Parent
local humanoid = character.Humanoid
local rootpart = character.HumanoidRootPart
humanoid.BreakJointsOnDeath = false -- !don't remove the joints and accessories will fall off
humanoid.Died:Connect(function() -- !rarely sometimes doens't fire even though character is dead (mostly likely the character hasn't loaded in)
print('died')
rootpart:SetNetworkOwner(nil)--! don't remove else character will get teleported back after flung
--code for character dead bodies
local model = Instance.new("Model") -- !needs to be a new model otherwise character will despawn
model.Parent = workspace
for _, part in pairs(character:GetChildren()) do
if part.Name == "HumanoidRootPart" then continue end -- !do not remove, makes character jitter
part.Parent = model --puts character parts into model (dead body)
end
end)
I’m almost a year late for this, but is there any way to stop the accessories of the body from being moved to the new player’s character?
It would be the same thing as checking the HumanoidRootPart, instead just add a check for what type the item is. Example below (not tested but should work in theory):
for _, part in pairs(character:GetChildren()) do
if part.Name == "HumanoidRootPart" or part:IsA("Accessory") then continue end
part.Parent = model
end
I’ve tried that; the code made by IceCreamPickels works so it just parents the parts onto a new model (pretty sure), but if the player respawns, it applies the accessories back onto the main and functional body, not the dead one.
Just little bit changed it
game.Players.PlayerAdded:Connect(function(player)
player.CharacterAdded:Connect(function(character)
character:FindFirstChild("Humanoid").Died:Connect(function()
local model = Instance.new("Model")
model.Parent = workspace
for _, part in pairs(character:GetChildren()) do
if not part:IsA("MeshPart") then continue end --you can rewrite that
part.Parent = model
end
end)
end)
end)
So If using R6, I just replace MeshPart with Part right?
I mean if I replace it, it doesn’t work
OH MY GOD THANK YOU SO MUCH FOR THAT
I really needed it