@BrAlMeSo_Mc & @223WinardKnot1
I’ve created a solution for this problem, and it does work! Instead of waiting for the character to be removed, just check whenever a child, or a decendant in this instance has been removed, and if the item is a model and is found in the Players Countainer.
game.Workspace.DescendantRemoving:Connect(function(Item)
spawn(function()
if Item:IsA("Model") and game.Players:FindFirstChild(Item.Name) then
warn(Item.Name.." has been destroyed, attempting to respawn the player.")
task.delay(game.Players.RespawnTime,function()
if not game.Workspace:FindFirstChild(game.Players:FindFirstChild(Item.Name).Name) then
game.Players[Item.Name]:LoadCharacter();warn("RESPAWNED PLAYER")
elseif game.Workspace:FindFirstChild(game.Players:FindFirstChild(Item.Name).Name) then
warn("PLAYER IS ALREADY SPAWNED")
end
end)
end
end)
end)
I would advise against this, as in a game typically speaking workspace has a lot of instances being added and removed from it. This might solve your problem, but is it really the most efficient way of doing so? Let’s take a look. You’re creating a ragdoll system, and your method of doing so is also pretty complicated.
My advice to you would be to change your code in the “Script” section you attached to this. I have gone through and modified the code to the best of my ability with coherent annotations. I hope you find this helpful!
--[[Made by Just2Terrify]]
--[[Players Character Added]]
local Protocol = require(game.ServerScriptService.Server_J2T_Control_Center.Modules.Functions) --This should only be required once, instead of each time a player is added. Module scripts only need to be required once.
local RESPAWN_DELAY = 3 --Set whatever your respawn duration preference is here
local CharacterAddedConnections = {} --This will be a table of all the connections we are using, not properly disconnecting your connections will lead to memory issues later down the road.
local CharacterDiedConnections = {}
game:GetService("Players").PlayerAdded:Connect(function(Player)
local CharacterAddedCheck
CharacterAddedCheck = Player.CharacterAdded:Connect(function(Character) --//Characters can spawn over and over, meaning we will be making a unique connection every time the player respawns. So, we will disconnect any previous death connections made.
if CharacterDiedConnections[Player.Name] then
if typeof(CharacterDiedConnections[Player.Name]) == "RBXScriptConnection" then
CharacterDiedConnections[Player.Name]:Disconnect()--//Always disconnect connections that could lead to memory consumption!!
end
CharacterDiedConnections[Player.Name] = nil
end
task.spawn(Protocol.Functions["Ragdoll Rig Builder"].Function,Player,Character)
local Humanoid = Character:WaitForChild("Humanoid")
local CharacterDeathCheck
CharacterDeathCheck = Humanoid.Died:Connect(function() --//We make a new character death check connection every time the player respawns!
task.spawn(Protocol.Functions["Death Ragdoll"].Function,Player,Character)
task.wait(RESPAWN_DELAY)
if Player and Player:IsDescendantOf(game.Players) then else return end
local Character = Player.Character
if typeof(Character) ~= "Instance" or not Character:IsDescendantOf(workspace) then
Player:LoadCharacter()
end
end)
CharacterDiedConnections[Player.Name] = CharacterDeathCheck
end)
CharacterAddedConnections[Player.Name] = CharacterAddedCheck
end)
game.Players.PlayerRemoving:Connect(function(Player) --//When players are removing, it's important to remember to disconnect any connections we have made to conserve memory!!
if Player and Player.Name then else return end
if CharacterAddedConnections[Player.Name] then
if typeof(CharacterAddedConnections[Player.Name]) == "RBXScriptConnection" then
CharacterAddedConnections[Player.Name]:Disconnect()--//Always disconnect connections that could lead to memory consumption!!
end
CharacterAddedConnections[Player.Name] = nil
end
if CharacterDiedConnections[Player.Name] then
if typeof(CharacterDiedConnections[Player.Name]) == "RBXScriptConnection" then
CharacterDiedConnections[Player.Name]:Disconnect()--//Always disconnect connections that could lead to memory consumption!!
end
CharacterDiedConnections[Player.Name] = nil
end
end)
This should have entirely fixed your issue. I downloaded the place you provided and changed the scripts accordingly. I tested it myself in studio.
Go to your “Functions” module script and paste this.
--[[Made by Just2Terrify]]
local Protocol = {}
Protocol.Ragdolls = {};
Protocol.Functions = {
["Ragdoll Rig Builder"] = {
Description = "Builds a ragdoll for each character that spawns.",
Function = function(Player,Character)
local Ragdoll = require(game.ServerScriptService.Server_J2T_Control_Center.Modules.Ragdolls)
local Humanoid = Character:FindFirstChild("Humanoid")
Ragdoll.Functions["Build Rig"].Function(Character)
if not table.find(Protocol.Ragdolls,Player.Name) then
Protocol.Ragdolls[Player] = Character:GetAttributeChangedSignal("Ragdoll"):Connect(function()
if Character:GetAttribute("Ragdoll") then
Ragdoll.Functions["Activate Ragdoll"].Function(Player.Name,true,Enum.HumanoidStateType.Physics,true)
elseif not Character:GetAttribute("Ragdoll") then
Ragdoll.Functions["Activate Ragdoll"].Function(Player.Name,false,Enum.HumanoidStateType.GettingUp,true)
end
end)
end
warn(Character.Name.." Ragdoll Built, BreakJoints & Require Neck is false.")
return
end,
},
["Death Ragdoll"] = {
Description = "Activates a death ragdoll.",
Function = function(plr,Char)
local Ragdoll = require(game.ServerScriptService.Server_J2T_Control_Center.Modules.Ragdolls);warn(plr.Name.." has died, the death ragdoll has been activated.");Ragdoll.Functions["Activate Ragdoll"].Function(plr.Name,true,Enum.HumanoidStateType.Physics,false)
return
end,
},
}
return Protocol
I believe the issue is that the script is running so fast; that the functions script can’t find the humanoid. I tried putting a WaitForChild, and a FindFirstChild on line 13, but it still didn’t work.
--[[Made by Just2Terrify]]
local Protocol = {}
Protocol.Ragdolls = {};
Protocol.Functions = {
["Ragdoll Rig Builder"] = {
Description = "Builds a ragdoll for each character that spawns.",
Function = function(plr,Char)
local Ragdoll = require(game.ServerScriptService.Server_J2T_Control_Center.Modules.Ragdolls);local Hum = Char:FindFirstChild("Humanoid")
Ragdoll.Functions["Build Rig"].Function(Char)
if not table.find(Protocol.Ragdolls,plr.Name) then
Protocol.Ragdolls[plr] = game.Workspace[plr.Name]:GetAttributeChangedSignal("Ragdoll"):Connect(function()
if game.Workspace[plr.Name]:GetAttribute("Ragdoll") == true then
Ragdoll.Functions["Activate Ragdoll"].Function(plr.Name,true,Enum.HumanoidStateType.Physics,true)
elseif game.Workspace[plr.Name]:GetAttribute("Ragdoll") == false then
Ragdoll.Functions["Activate Ragdoll"].Function(plr.Name,false,Enum.HumanoidStateType.GettingUp,true)
end
end)
end
warn(Char.Name.." Ragdoll Built, BreakJoints & Require Neck is false.")
return
end,
},
["Death Ragdoll"] = {
Description = "Activates a death ragdoll.",
Function = function(plr,Char)
local Ragdoll = require(game.ServerScriptService.Server_J2T_Control_Center.Modules.Ragdolls);warn(plr.Name.." has died, the death ragdoll has been activated.");Ragdoll.Functions["Activate Ragdoll"].Function(plr.Name,true,Enum.HumanoidStateType.Physics,false)
return
end,
},
}
return Protocol
Hey, I have a suggestion that might fix the warning you are getting in the output. Before you destroy the old character set the players character property to the new ragdoll clone. You can do this like so:
Sadly, it still has not. The ragdoll still does not activate, and i’m unsure as to why. It says the death ragdoll was activated when the ragdoll toggle is triggered. Current place file with your suggested updates. (139.9 KB)
Don’t delete the old player, just make it fully transparent (set walkspeed and jumpheight to 0), spawn in the ragdoll, and set the ragdoll to be the target of the camera. Wait five seconds, and then call :LoadCharacter()
Or better yet, just replace the Motor6D joints in the player with ball and socket joints on death? This eliminates the need with an extra ragdoll player, and you can just wait five seconds and respawn the player as normal, and you can just replace the ball and socket joints with Motor6D joints to unragdoll the player.
My guess is that the issues are having to do with your character model itself? Not entirely sure. Try taking all accessories off your character including 3D mesh body parts.
It works fine for me, using the same place download you provided. Video
My suggestions:
Set Players.CharacterAutoLoads to false, making it to where roblox will not spawn nor respawn characters.
In PlayerAdded function:
connect to character added function
local hum = char:WaitForChild(“Humanoid”)
hum.BreakJointsOnDeath = false
hum.Died:Wait() – waits until character dies
disable Motor6D
enable ragdoll joins
wait(3)
Player.Character = nil
Player:LoadCharacter()
end)
Player:LoadCharacter() – to load initially
dont use this >
Workaround:
in a ServerScriptService Script:
put the functions that are in charge of ragdolling, waiting, and then unragdolling in _G table.
example:
_G.RagdollChar(Char, TimeFinished)
-- ragdoll Char
wait(TimeFinished)
-- unragdoll
end
dont use this ^
Another thing, I’ve been having trouble with cloning the character because for some reason Roblox is setting the Character model’s Archivable boolean to false. Set that to true and then clone.
Actually I feel stupid for saying the _G.RagdollChar thing. That won’t work because it’s still running in the same thread as the script who is calling it.
Instead maybe create a BindableEvent or BindableFunction that you can fire so a different script that won’t stop because a player leaves can pick up on it and will run the ragdoll code.
I haven’t needed to make the players walkspeed or jumpheight 0 yet. I’m assuming you do this to prevent the character from breaking through the ragdoll and unragdolling?
Outside of that, I’m already doing all of this… the issue is that the ragdoll won’t create itself when the character spawns with an R15 RigType. Any ideas of how to counteract that?