Target Dies When Touching Hitbox

You can write your topic however you want, but you need to answer these questions:

  1. What do you want to achieve? Keep it simple and clear!
    Somehow the hitbox in the server script kills the target instantly, i do not want that to happen, i just want them to be knocked back and ragdolled***

  2. What is the issue? Include screenshots / videos if possible!

  3. What solutions have you tried so far? Did you look for solutions on the Creator Hub?
    I tried looking it up, but i just dont know how it happens, so I came here if anyone knows about it

The Hitbox Script

M1Event.OnServerEvent:Connect(function(player,Type)
	local character = player.Character
	if character:GetAttribute("Stunned") then return end
	local HRP : BasePart = character:FindFirstChild("HumanoidRootPart")
	local humanoid = character:FindFirstChildOfClass("Humanoid")
	local Animator = humanoid:FindFirstChildOfClass("Animator")
	
	local uppercutTrack
	if Type == "Fast" then
		local randomTrack = Anims[math.random(1,#Anims)]
		uppercutTrack = Animator:LoadAnimation(randomTrack)
	else
		uppercutTrack = Animator:LoadAnimation(Mahoraga.Uppercut)
	end
	uppercutTrack.Priority = Enum.AnimationPriority.Action2
	uppercutTrack:Play()
	
	local Swing = script.Swing:Clone()
	Swing.Parent = Mahoraga.PrimaryPart
	Swing:Play()
	game.Debris:AddItem(Swing,Swing.TimeLength)
	
	local Hitbox = Utilities:CreateHitbox(HRP,{Size = Vector3.new(9,9,9),Time = 0.5})
	local db = {}
	
	table.clear(db)
	
	Hitbox.Touched:Connect(function(hit)
		local hum = hit.Parent:FindFirstChildOfClass("Humanoid")
		
		if hum then
			if table.find(db,hit.Parent) then return end
			
			table.insert(db,hit.Parent)
			local targetRoot = hit.Parent:FindFirstChild("HumanoidRootPart")
			local targetPlayer = game.Players:GetPlayerFromCharacter(hit.Parent)
			
			Effect:Ring(targetRoot.CFrame)
			Effect:Ring(targetRoot.CFrame,Vector3.new(20,0.4,20))
			Effect:Glow(hit.Parent,Color3.fromRGB(134, 134, 134),0.1)
			
			if Type == "Fast" then
				Glove:Slash(Mahoraga.Owner,hit.Parent,HRP.CFrame.LookVector * 7,1,5)
				
				local Slice = script.Slice:Clone()
				Slice.Parent = Mahoraga.PrimaryPart
				Slice:Play()
				game.Debris:AddItem(Slice,Slice.TimeLength)
			elseif Type == "Medium" then
				Events.CustomShake:FireClient(player,1,1,0,1)
				Glove:Slash(Mahoraga.Owner,hit.Parent,HRP.CFrame.LookVector * 15 + Vector3.new(0,5,0),2,5)
				
				local PunchMed = script.PunchMed:Clone()
				PunchMed.Parent = Mahoraga.PrimaryPart
				PunchMed:Play()
				game.Debris:AddItem(PunchMed,PunchMed.TimeLength)
				
				local Slice = script.Slice:Clone()
				Slice.Parent = Mahoraga.PrimaryPart
				Slice:Play()
				game.Debris:AddItem(Slice,Slice.TimeLength)	
			elseif Type == "Heavy" then
				Events.CustomShake:FireClient(player,4,4,0,1)
				if targetPlayer then
					Events.CustomShake:FireClient(player,4,4,0,1)
				end
				
				Glove:Slash(Mahoraga.Owner,hit.Parent,HRP.CFrame.LookVector * 30 + Vector3.new(0,15,0),3,5)
				
				local PunchHeavy = script.PunchHeavy:Clone()
				PunchHeavy.Parent = Mahoraga.PrimaryPart
				PunchHeavy:Play()
				game.Debris:AddItem(PunchHeavy,PunchHeavy.TimeLength)
				
				local Slice = script.Slice:Clone()
				Slice.Parent = Mahoraga.PrimaryPart
				Slice:Play()
				game.Debris:AddItem(Slice,Slice.TimeLength)
			end
			
		end
	end)
end)

The Module That’s Being used While Ragdolling

function GloveModule:Slash(own,target : Model,velocity,RTG,Power)
	local Invincible = target:GetAttribute("Invincible")
	
	local Bruised = target:GetAttribute("Bruised")
	local Endurance = target:GetAttribute("Endurance")
	local Reflection = target:GetAttribute("Reflection")
	
	local RagdollMult = (Glove and Glove.RagdollMultiplier and Glove.RagdollMultiplier.Value) or 1
	local KnockbackMult = (Glove and Glove.KnockbackMultiplier and Glove.KnockbackMultiplier.Value) or 1
	local AngularMult = (Glove and Glove.AngularMultiplier and Glove.AngularMultiplier.Value) or 1
	
	local RagdollResistance = target:GetAttribute("RagdollResistance")
	
	local Player : Player = Players:FindFirstChild(own.Value)
	local targetPlayer : Player = Players:FindFirstChild(target.Name)
		
	if targetPlayer and targetPlayer.Neutral == false then
		if Player.TeamColor == targetPlayer.TeamColor then
			print(Player.Name.." is on the same team with "..targetPlayer.Name)
			return
		end
	end
	
	if RagdollResistance then
		RTG = RTG - RagdollResistance
	end
	
	RTG = RTG * RagdollMult
	
	if Invincible then
		print(target.Name.." is invincible")
		return
	end

	if target == Player.Character or (targetPlayer and targetPlayer == Player) then
		print(target.Name.." is same target")
		return
	end
	
	local targetHumanoid = target:FindFirstChildOfClass("Humanoid")
	local targetHRP = target:FindFirstChild("HumanoidRootPart")

	if not targetHumanoid or not targetHRP then
		print("no humanoid or root")
		return
	end
	
	local flingvelocity = velocity * 5
	local spinvelocity = velocity * 0.5
	
	if Reflection then
		local bv = Instance.new("BodyVelocity")
		bv.Parent = Player.Character:WaitForChild("HumanoidRootPart")
		bv.MaxForce = Vector3.new(1e8,1e8,1e8)
		local velocity = -flingvelocity + Vector3.new(0, Power + 10, 0) * KnockbackMult

		if Bruised and Bruised > 0 then
			velocity += velocity.Unit * Bruised
		end
		if Endurance and Endurance > 0 then
			velocity -= velocity.Unit * Endurance
		end
		
		bv.Velocity = velocity

		local bav = Instance.new("BodyAngularVelocity")
		bav.Parent = Player.Character:WaitForChild("HumanoidRootPart")
		bav.AngularVelocity = flingvelocity + Vector3.new(0,Power,0) * AngularMult
		
		game.Debris:AddItem(bv,0.3)
		game.Debris:AddItem(bav,0.2)

		local CharRagdoll = Ragdoll.new(Player.Character, {
			CollisionsEnabled = true,
			RagdollType = "Toggle",
			RemovalTime = RTG
		})

		task.spawn(function()
			CharRagdoll:doRagdoll(true)
			task.wait(RTG)
			CharRagdoll:doRagdoll(false)
		end)
		
		local value = Instance.new("BoolValue")
		value.Name = "SLAPPED"
		value.Value = true
		value.Parent = target
		
		task.delay(RTG,function()
			wait(RTG)
			value:Destroy()
		end)
		
		return
	end
	
	local leaderstats = Player:FindFirstChild("leaderstats")
	local Slaps = leaderstats:FindFirstChild("Slaps")
	
	if Slaps then
		Slaps.Value += 1
	end

	local CharRagdoll = Ragdoll.new(target, {
		CollisionsEnabled = true,
		RagdollType = "Toggle",
		RemovalTime = RTG
	})
	
	task.spawn(function()
		CharRagdoll:doRagdoll(true)
		task.wait(RTG)
		CharRagdoll:doRagdoll(false)
	end)
	
	local TargetHRP = target:FindFirstChild("HumanoidRootPart")
	
	local bv = Instance.new("BodyVelocity")
	bv.Parent = target:WaitForChild("HumanoidRootPart")
	bv.MaxForce = Vector3.new(1e8,1e8,1e8)
	local velocity = flingvelocity + Vector3.new(0, Power + 10, 0) * KnockbackMult

	if Bruised and Bruised > 0 then
		velocity += velocity.Unit * Bruised
	end
	if Endurance and Endurance > 0 then
		velocity -= velocity.Unit * Endurance
	end

	bv.Velocity = velocity

	local bav = Instance.new("BodyAngularVelocity")
	bav.Parent = target:WaitForChild("HumanoidRootPart")
	bav.AngularVelocity = flingvelocity + Vector3.new(0,Power,0) * AngularMult

	target.Humanoid:ChangeState(Enum.HumanoidStateType.Physics)

	local value = Instance.new("BoolValue")
	value.Name = "SLAPPED"
	value.Value = true
	value.Parent = target

	game.Debris:AddItem(bv,0.3)
	game.Debris:AddItem(bav,0.2)
	

	task.delay(RTG,function()
		wait(RTG)
		value:Destroy()
	end)
end

Sorry for no comments, im just like that :sob:

Also, I think this happens because of this maybe, It switches the player’s character, this doesn’t happen with other scripts that use this module, it may be an issue with the character

Events.SetCamera:FireClient(player,Mahoraga.Humanoid)
				player.Character = Mahoraga
				
				Mahoraga.Owner.Value = player.Name
				Mahoraga.CameraOffset.Enabled = true
				Mahoraga.Animate.Enabled = true
				Mahoraga.Ability.Enabled = true
				Mahoraga.RagdollScript.Enabled = true
				Mahoraga.Highlight:Destroy()

The Issue:


For some reason, i tried it many times, this issue doesnt happen with non-player characters:

1 Like

Looking at your code, I don’t see anything that causes the player to die instantly. If i had to guess, it may have something to do with your ragdoll module given that npcs don’t die (it might be improperly destroy Motor6D/joints)

i’ve linked a potential solution below that just stop players from dying entirely

Prevent players from dying at or below 0 hp

As @KylrrH mentioned above, Motor6D/joints being improperly destroyed might cause this issue. I would like you to send your ragdoll code or any code that relates to Motor6D, and comment out those ragdoll functions in the hitbox code block to see if it doesn’t kill the player right away.

1 Like

Here is the ragdoll module, im using someone else’s, but it is kinda edited by me

--[[

  ____                 _       _ _   __  __           _       _      
 |  _ \ __ _  __ _  __| | ___ | | | |  \/  | ___   __| |_   _| | ___ 
 | |_) / _` |/ _` |/ _` |/ _ \| | | | |\/| |/ _ \ / _` | | | | |/ _ \
 |  _ < (_| | (_| | (_| | (_) | | | | |  | | (_) | (_| | |_| | |  __/
 |_| \_\__,_|\__, |\__,_|\___/|_|_| |_|  |_|\___/ \__,_|\__,_|_|\___|
             |___/                                                   
 by @igd3v, v1.2.1
 
 CHANGES
 - v1.1:
 	> Now you can ragdoll characters without destroying them.
 	> Fixed AutoDestroy cleanup to make it actually cleanup
 	> Fixed a typo in cloneModel
 	> Added Types.RagdollType
 	> Added Types.RagdolCache
 	> Added the "Ragdoll:setRagdollType()" method
 	> Added "_ragdollCache" table to save joints and reuse them.
 - v1.1.1:
 	> Fixed error that caused :doRagdoll to not work.
 	> Fixed physics collisions for rig compatibility.
 	> Fixed Network Owner Management.
 	> Fixed _ragdollCache management.
 - v1.1.2:
 	> Fixed ragdolls with DeathBody Type.
 	> Fixed the constraint joining method.
 	> Fixed and restructured code in :doRagdoll().
 	> Made ragdoll collision hitboxes a bit smaller
 	> Added debug mode
 - v1.2:
 	> Added the TwistAngleRange variable.
 	> Now you can set all your values in one go.
 	> WARNING; PLEASE UPDATE YOUR .new() CALLS TO THE NEW FORMAT: .new(Character:Model, DataTable:RagdollProperties)
 - v1.2.1:
 	> Now you can call Ragdoll:destroy() to destroy the ragdoll object.
 	> Now you can access other ragdoll from the module by using getRagdoll()
 	> Now you can check if the ragdoll is currently ragdolling with ragdoll:isRagdolling()
 	> You can also now define a custom ID for the ragdoll to be stored in. (i.e. ragdoll with id "hello" will be stored as ragdolls["hello"])
]]

local TweenService = game:GetService("TweenService")
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local RunService = game:GetService("RunService")
local HTTPService = game:GetService("HttpService")

local Sounds = ReplicatedStorage:FindFirstChild("Sounds")
local Storage = ReplicatedStorage:FindFirstChild("Storage")
local FX = ReplicatedStorage:FindFirstChild("FX")

local Modules = Storage:FindFirstChild("Modules")
local Combat  = FX:FindFirstChild("Combat")
local RagdollSounds = Sounds:FindFirstChild("Ragdoll")

local RagdollSoundTable = RagdollSounds:GetChildren()

local Util = require(Modules.Utilities)

local ConcreteTable = {
	Enum.Material.Concrete,
	Enum.Material.Plastic,
	Enum.Material.SmoothPlastic,
	Enum.Material.Brick,
	Enum.Material.Plaster
}
local Types = require(script.Types)

local ragdoll = {} :: Types.Ragdoll
ragdoll.__index = ragdoll

local ragdolls = {} :: {Types.Ragdoll}

local function cloneModel(model:Model)
	local wasArchivable = false
	if not model.Archivable then
		model.Archivable = true
	end
	
	local clone = model:Clone()
	
	return clone
end

local function join(joint: Motor6D?, twistAngleRange: number, destroyOld: boolean):(BallSocketConstraint, Motor6D?)
	local socketName = joint.Name:gsub("%s+", "") .. "Socket"

	local existingSocket = joint.Parent:FindFirstChild(socketName)
	if existingSocket then
		return existingSocket
	end

	local socket = Instance.new("BallSocketConstraint")
	socket.Name = socketName

	local a1 = joint.Part0:FindFirstChild(socketName .. "_A0")
	local a2 = joint.Part1:FindFirstChild(socketName .. "_A1")

	if not a1 then
		a1 = Instance.new("Attachment")
		a1.Name = socketName .. "_A0"
		a1.CFrame = joint.C0
		a1.Parent = joint.Part0
	end

	if not a2 then
		a2 = Instance.new("Attachment")
		a2.Name = socketName .. "_A1"
		a2.CFrame = joint.C1
		a2.Parent = joint.Part1
	end

	socket.Parent = joint.Parent

	socket.Attachment0 = a1
	socket.Attachment1 = a2

	socket.LimitsEnabled = true
	socket.TwistLimitsEnabled = true

	socket.TwistLowerAngle = -(twistAngleRange / 2)
	socket.TwistUpperAngle = twistAngleRange / 2

	if destroyOld then
		joint.Part0 = nil
		joint.Part1 = nil
		joint.Enabled = false

		joint:Destroy()
	end

	return socket
end

local function initRagdollFolder()
	if workspace:FindFirstChild("__ragdoll") then return workspace:FindFirstChild("__ragdoll") end
	
	local folder = Instance.new("Folder")
	folder.Name = "__ragdoll"
	folder.Parent = workspace
	
	return folder
end

local function initCollisionGroup()
	if not game.PhysicsService:IsCollisionGroupRegistered("__ragdollColl") then
		game.PhysicsService:RegisterCollisionGroup("__ragdollColl")
		game.PhysicsService:CollisionGroupSetCollidable("Default", "__ragdollColl", true)
		game.PhysicsService:CollisionGroupSetCollidable("__ragdollColl", "__ragdollColl", false)
	end
end

local function getRagdollModel(ragType:Types.RagdollType, src:Model?):Model?
	if not src then return end
	
	if ragType == "DeathBody" then
		return cloneModel(src)
	elseif ragType == "Toggle" then
		return src
	end
end

local function createOrGetCollisionBox(child:BasePart):(Part, Weld)
	if child:FindFirstChild("_collision") and child:FindFirstChild("_collision"):FindFirstChildOfClass("Weld") then
		return child:FindFirstChild("_collision"), child:FindFirstChild("_collision"):FindFirstChildOfClass("Weld")
	end
	
	local collisionBox = Instance.new("Part")
	collisionBox.Size = child.Size * 0.75

	collisionBox.CanCollide = true
	
	collisionBox.Transparency = 1
	collisionBox.CanTouch = false
	collisionBox.CanQuery = false

	collisionBox.CollisionGroup = "__ragdollColl"

	local weld = Instance.new("Weld")

	weld.Part0 = child
	weld.Part1 = collisionBox

	collisionBox.Name = `_collision`
	collisionBox.Parent = child
	weld.Parent = collisionBox
	
	return collisionBox, weld
end

local function tryStoreRagdoll(obj:Types.Ragdoll, id:string)
	if ragdolls[id] then
		error("Ragdoll already exists at key "..id)
	end
	
	ragdolls[id] = obj
end

-- Creates a new ragdoll handler.
function ragdoll.new(Character:Model, DataTable:Types.RagdollProperties)
	assert(Character, "Ragdoll Character is required.")
	assert(typeof(DataTable) == "table", "The .new() method has been updated and its old use has been deprecated. Please use the new format: new(Character:Model, DataTable:RagdollProperties)")
	local self = (setmetatable({}, ragdoll)::unknown)::Types.Ragdoll
	
	self.Character = Character
	self.RemovalTime = DataTable.RemovalTime or 5
	self.CollisionsEnabled = DataTable.CollisionsEnabled or true
	self.DoFadeOnRemovalReached = DataTable.DoFadeOnRemovalReached or true
	self.FadeTime = DataTable.FadeTime or 10
	self.Friction = DataTable.Friction or 0.25
	self.Elasticity = DataTable.Elasticity or 0.7
	self.Density = DataTable.Density or 0.5
	self.Player = DataTable.Player or nil
	self.AutoDestroy = DataTable.AutoDestroy or true
	self.RagdollType = DataTable.RagdollType or "DeathBody"
	self.DebugMode = DataTable.DebugMode or false
	self.TwistAngleRange = DataTable.TwistAngleRange or 45
	
	self._ragdollCache = {}
	self._ragdollGUID = DataTable.ID or HTTPService:GenerateGUID()
	self._ragdolling = false
	
	tryStoreRagdoll(self, self._ragdollGUID)
	
	if Character then
		local Humanoid = Character:WaitForChild("Humanoid", 5)
		if Humanoid then
			Humanoid.BreakJointsOnDeath = false
		end
	end
	
	return self
end

function ragdoll:destroy()
	if ragdolls[self._ragdollGUID] then
		ragdolls[self._ragdollGUID] = nil
	end
	
	table.clear(self)
	setmetatable(self, nil)
end

function ragdoll:debug(msg)
	if self.DebugMode then
		print(`[DEBUG][RagdollModule]: {tostring(msg)}`)
	end
end

-- Sets the Ragdoll type
function ragdoll:setRagdollType(ragdollType:Types.RagdollType)
	if not ragdollType then return false end
	self.RagdollType = ragdollType
	return true
end


function ragdoll:Knockback(hit : BasePart,targetRoot : BasePart,Direction : Vector3,Duration)
	local CharRagdoll = ragdoll.new(hit.Parent, {
		CollisionsEnabled = true,
		RagdollType = "Toggle",
		AutoDestroy = true,
		RemovalTime = Duration,
	})

	CharRagdoll:doRagdoll(true)

	task.delay(Duration or 2,function()
		CharRagdoll:doRagdoll(false)
	end)

	local BodyVelocity = Instance.new("BodyVelocity")

	BodyVelocity.P = 5000
	BodyVelocity.MaxForce = Vector3.new(math.huge,math.huge,math.huge)
	BodyVelocity.Velocity = Direction
	BodyVelocity.Parent = targetRoot
	
	local BodyAngularVelocity = Instance.new("BodyAngularVelocity")
	BodyAngularVelocity.AngularVelocity = Direction
	BodyAngularVelocity.Parent = targetRoot
	
	game.Debris:AddItem(BodyVelocity,0.25)
	game.Debris:AddItem(BodyAngularVelocity,0.2)
end

function ragdoll:Dismember(character: Model, limbName: string)
	for _, obj in ipairs(character:GetDescendants()) do
		if obj:IsA("BallSocketConstraint") then
			if obj.Name:find(limbName:gsub("%s+", "")) then
				obj:Destroy()
			end
		end
	end
end

-- Starts the ragdoll simulation and removes it after the time specified.
function ragdoll:doRagdoll(toggle:boolean):boolean
	local success, err = pcall(function()	
		initCollisionGroup()
		self:debug(initRagdollFolder())
		
		local characterRagdoll = getRagdollModel(self.RagdollType, self.Character)
		self:debug(characterRagdoll)
		
		local characterHumanoid = characterRagdoll:FindFirstChildOfClass("Humanoid")
		self:debug(characterHumanoid)
		
		if self.RagdollType == "Toggle" and toggle then
			
			task.delay(self.RemovalTime or 10, function()
				-- hala ragdolldaysa geri aç
				if self and self:isRagdolling() then
					self:doRagdoll(false)
				end
			end)
			
		end
		
		if characterHumanoid then
			characterHumanoid.PlatformStand = (self.RagdollType == "DeathBody") or (self.RagdollType == "Toggle" and toggle)

			local animator = characterHumanoid:FindFirstChildOfClass("Animator")

			for _, track in ipairs(animator:GetPlayingAnimationTracks()) do
				if track then
					track:Stop()
				end
			end
			
			if self.RagdollType == "DeathBody" then
				characterHumanoid.DisplayDistanceType = Enum.HumanoidDisplayDistanceType.None
				characterHumanoid.BreakJointsOnDeath = false
				characterHumanoid.Health = -math.huge
			elseif self.RagdollType == "Toggle" and toggle == false then
				-- Force Wake Up
				characterHumanoid:ChangeState(Enum.HumanoidStateType.GettingUp)
				print("getting up")

				-- Prevent any flings
				local rootPart = characterRagdoll:FindFirstChild("HumanoidRootPart")
				if rootPart then
					rootPart.AssemblyLinearVelocity = Vector3.zero
					rootPart.AssemblyAngularVelocity = Vector3.zero
				end
			end
		end
		
		--Ragdoll Wind
		local HRP = characterRagdoll:FindFirstChild("HumanoidRootPart")
		self.RagdollWindConnection = RunService.Heartbeat:Connect(function()
			if not HRP then return end

			local velocity = HRP.AssemblyLinearVelocity.Magnitude
			if velocity < 100 then 
				if HRP:FindFirstChild("RagdollWind") then
					HRP.RagdollWind:Destroy()
				end
				return 
			end

			if not HRP:FindFirstChild("RagdollWind") then
				local RagdollFX = Combat.RagdollWind:Clone()
				RagdollFX.Name = "RagdollWind"
				RagdollFX.Parent = HRP
				RagdollFX.CFrame = HRP.CFrame
				Util:Weld(RagdollFX, HRP)
			end
			
		end)
		
		local lastVelocity = {}

		RunService.Heartbeat:Connect(function()
			for _, part in characterRagdoll:GetDescendants() do
				if part:IsA("BasePart") then
					lastVelocity[part] = part.AssemblyLinearVelocity.Magnitude
				end
			end
		end)
		
		for _, child in characterRagdoll:GetChildren() do
			--RagdollSound
			local fallSoundDebounce = false
			
			self.RagdollSoundConnection = HRP.Touched:Connect(function(hit)
				if not self.CollisionsEnabled then return end
				if fallSoundDebounce then return end
				if not hit or not hit:IsA("BasePart") then return end
				if hit.Parent == characterRagdoll then return end

				local currentVelocity = HRP.AssemblyLinearVelocity.Magnitude
				local previousVelocity = lastVelocity[HRP] or 0

				if previousVelocity > 60 and currentVelocity < 15 then
					fallSoundDebounce = true

					local RandomSound = RagdollSoundTable[math.random(1,#RagdollSoundTable)]:Clone()
					RandomSound.Parent = HRP
					RandomSound:Play()

					game.Debris:AddItem(RandomSound, RandomSound.TimeLength)
					
					task.delay(1, function()
						fallSoundDebounce = false
					end)
				end
			end)
			
			
			
			
			if self.CollisionsEnabled then
				if child:IsA("BasePart") then
					local box, weld = createOrGetCollisionBox(child)
					if not self._ragdollCache[child] then
						self._ragdollCache[child] = {}
					end
					
					if self._ragdollCache[child] and not self._ragdollCache[child].OldCollisionGroup then
						self._ragdollCache[child].OldCollisionGroup = child.CollisionGroup
					end
					
					if self.RagdollType == "Toggle" then
						box.CanCollide = toggle
						box.Massless = not toggle
						child.CollisionGroup = (toggle and "__ragdollColl") or self._ragdollCache[child].OldCollisionGroup
					elseif self.RagdollType == "DeathBody" then
						box.CanCollide = true
						box.Massless = false
						child.CollisionGroup = "__ragdollColl"
					end
					
					if self.DebugMode then
						box.Transparency = 0.5
						box.Material = Enum.Material.Plastic
						box.Color = Color3.new(1,0,0)
						
						child.Transparency = 0.5
					end
				end
			end
		end
		
		for _, child in characterRagdoll:GetDescendants() do
			if (child:IsA("LocalScript") or child:IsA("Script") or child:IsA("ForceField")) and self.RagdollType == "DeathBody" then
				child:Destroy()
			end
		end
		
		characterRagdoll.Parent = (self.RagdollType == "DeathBody" and initRagdollFolder()) or characterRagdoll.Parent
		self:debug(characterRagdoll.Parent)
		
		wait()
		
		for _, child in characterRagdoll:GetDescendants() do
			if child:IsA("BasePart") then
				child.CustomPhysicalProperties = ((self.RagdollType == "DeathBody" or (self.RagdollType == "Toggle" and toggle)) 
					and PhysicalProperties.new(self.Density, self.Friction, self.Elasticity))
					or nil

				if self.RagdollType == "DeathBody" then
					child.CanQuery = false
					child.CanTouch = false
				end
				
				if self.Player and RunService:IsServer() then
					if (self.RagdollType == "Toggle" and toggle) or self.RagdollType == "DeathBody" then
						child:SetNetworkOwner(nil)
					else
						child:SetNetworkOwnershipAuto()
						if self.RagdollWindConnection then
							self.RagdollWindConnection:Disconnect()
							self.RagdollWindConnection = nil
						end
						
						if self.RagdollSoundConnection then
							self.RagdollSoundConnection:Disconnect()
							self.RagdollSoundConnection = nil
						end
					end
				end
			end
			
			if child:IsA("Motor6D") then
				if self.RagdollType == "Toggle" and self._ragdollCache[child] then
					local cache = self._ragdollCache[child]
					
					self._ragdollCache[child].Motor.Enabled = not toggle
					self._ragdollCache[child].BallSocket.Enabled = toggle

					if cache.BallSocket then
						if toggle then
							cache.BallSocket.Enabled = true
						else
							local socket = cache.BallSocket

							local a0 = socket.Attachment0
							local a1 = socket.Attachment1

							socket:Destroy()

							if a0 then
								a0:Destroy()
							end

							if a1 then
								a1:Destroy()
							end

							cache.BallSocket = nil
						end
					end
					
					
					continue
				end

				local ball = join(child, self.TwistAngleRange)
				
				self:debug(child)
				self:debug(ball)
				
				if self.RagdollType == "DeathBody" then
					child.Enabled = false
					ball.Enabled = true
				else
					if not self._ragdollCache[child] then
						self._ragdollCache[child] = {}
					end

					if ball and child then
						self._ragdollCache[child].Motor = child
						self._ragdollCache[child].BallSocket = ball
					end

					child.Enabled = not toggle
					ball.Enabled = toggle
				end
			end
		end
		
		if self.RagdollType == "DeathBody" then
			local doFade, fadeTime = self.DoFadeOnRemovalReached, self.FadeTime -- after cleanup these are nil
			
			task.delay(self.RemovalTime, function()
				if doFade then
					for _, child in characterRagdoll:GetDescendants() do
						if child:IsA("BasePart") or child:IsA("Decal") or child:IsA("Texture") then
							TweenService:Create(child, TweenInfo.new(fadeTime, Enum.EasingStyle.Linear), {
								Transparency = 1
							}):Play()
						end
					end
					
					game.Debris:AddItem(characterRagdoll, fadeTime)
				else
					game.Debris:AddItem(characterRagdoll, 0)
				end
			end)
			
			wait()
			
			characterRagdoll.PrimaryPart.AssemblyLinearVelocity = self.Character.PrimaryPart.AssemblyLinearVelocity
			characterRagdoll.PrimaryPart.AssemblyAngularVelocity = self.Character.PrimaryPart.AssemblyAngularVelocity
			
			self:debug(characterRagdoll.PrimaryPart.AssemblyLinearVelocity)
			self:debug(characterRagdoll.PrimaryPart.AssemblyAngularVelocity)

			local tag = Instance.new("ObjectValue")
			tag.Value = characterHumanoid
			tag.Name = "_ragdoll"

			tag.Parent = self.Character

			game.Debris:AddItem(tag, 3)
		end
	end)
	
	if success then
		self._ragdolling = (self.RagdollType == "DeathBody" and true) or self.RagdollType == "Toggle" and toggle
	end
	
	if self.RagdollType == "DeathBody" then
		for i,v in self.Character:GetDescendants() do
			if v:IsA("BasePart") or v:IsA("Texture") or v:IsA("Decal") then
				v.Transparency = 1
			end

			if v:IsA("BasePart") then
				v.CanCollide = false
				v.CanTouch = false
				v.CanQuery = false
				v.Anchored = true
			end

			if v:IsA("ForceField") then
				v:Destroy()
			end
		end
	end
	
	self:debug(success)
	self:debug(err)
	
	if self.AutoDestroy and self.RagdollType == "DeathBody" then
		self:destroy()
	end
	
	return success, err
end

function ragdoll:isRagdolling()
	return self._ragdolling == true
end

function ragdoll.getRagdoll(id:string)
	return ragdolls[id] or false
end

-- Deletes all the ragdolls inside the ragdoll folder.
function ragdoll.clearAll()
	initRagdollFolder():ClearAllChildren()
end

return ragdoll

Keep in my mind that i use this module for literally everything, but this issue doesn’t happen with other scripts that are using this module, happens for only the script i sent before

Hello, I have added some debug lines to see what is going to happen when you are using the module. You can paste this whole code in and record a video so that I can see the output.

--[[

  ____                 _       _ _   __  __           _       _      
 |  _ \ __ _  __ _  __| | ___ | | | |  \/  | ___   __| |_   _| | ___ 
 | |_) / _` |/ _` |/ _` |/ _ \| | | | |\/| |/ _ \ / _` | | | | |/ _ \
 |  _ < (_| | (_| | (_| | (_) | | | | |  | | (_) | (_| | |_| | |  __/
 |_| \_\__,_|\__, |\__,_|\___/|_|_| |_|  |_|\___/ \__,_|\__,_|_|\___|
             |___/                                                   
 by @igd3v, v1.2.1
 
 CHANGES
 - v1.1:
 	> Now you can ragdoll characters without destroying them.
 	> Fixed AutoDestroy cleanup to make it actually cleanup
 	> Fixed a typo in cloneModel
 	> Added Types.RagdollType
 	> Added Types.RagdolCache
 	> Added the "Ragdoll:setRagdollType()" method
 	> Added "_ragdollCache" table to save joints and reuse them.
 - v1.1.1:
 	> Fixed error that caused :doRagdoll to not work.
 	> Fixed physics collisions for rig compatibility.
 	> Fixed Network Owner Management.
 	> Fixed _ragdollCache management.
 - v1.1.2:
 	> Fixed ragdolls with DeathBody Type.
 	> Fixed the constraint joining method.
 	> Fixed and restructured code in :doRagdoll().
 	> Made ragdoll collision hitboxes a bit smaller
 	> Added debug mode
 - v1.2:
 	> Added the TwistAngleRange variable.
 	> Now you can set all your values in one go.
 	> WARNING; PLEASE UPDATE YOUR .new() CALLS TO THE NEW FORMAT: .new(Character:Model, DataTable:RagdollProperties)
 - v1.2.1:
 	> Now you can call Ragdoll:destroy() to destroy the ragdoll object.
 	> Now you can access other ragdoll from the module by using getRagdoll()
 	> Now you can check if the ragdoll is currently ragdolling with ragdoll:isRagdolling()
 	> You can also now define a custom ID for the ragdoll to be stored in. (i.e. ragdoll with id "hello" will be stored as ragdolls["hello"])
]]

local TweenService = game:GetService("TweenService")
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local RunService = game:GetService("RunService")
local HTTPService = game:GetService("HttpService")

local Sounds = ReplicatedStorage:FindFirstChild("Sounds")
local Storage = ReplicatedStorage:FindFirstChild("Storage")
local FX = ReplicatedStorage:FindFirstChild("FX")

local Modules = Storage:FindFirstChild("Modules")
local Combat  = FX:FindFirstChild("Combat")
local RagdollSounds = Sounds:FindFirstChild("Ragdoll")

local RagdollSoundTable = RagdollSounds:GetChildren()

local Util = require(Modules.Utilities)

local ConcreteTable = {
	Enum.Material.Concrete,
	Enum.Material.Plastic,
	Enum.Material.SmoothPlastic,
	Enum.Material.Brick,
	Enum.Material.Plaster
}
local Types = require(script.Types)

local ragdoll = {} :: Types.Ragdoll
ragdoll.__index = ragdoll

local ragdolls = {} :: {Types.Ragdoll}

local function cloneModel(model:Model)
	if not model.Archivable then
		model.Archivable = true
	end
	
	local clone = model:Clone()
	
	return clone
end

local function join(joint: Motor6D?, twistAngleRange: number, destroyOld: boolean):(BallSocketConstraint, Motor6D?)
	local socketName = joint.Name:gsub("%s+", "") .. "Socket"

	local existingSocket = joint.Parent:FindFirstChild(socketName)
	if existingSocket then
		return existingSocket
	end

	local socket = Instance.new("BallSocketConstraint")
	socket.Name = socketName

	local a1 = joint.Part0:FindFirstChild(socketName .. "_A0")
	local a2 = joint.Part1:FindFirstChild(socketName .. "_A1")

	if not a1 then
		a1 = Instance.new("Attachment")
		a1.Name = socketName .. "_A0"
		a1.CFrame = joint.C0
		a1.Parent = joint.Part0
	end

	if not a2 then
		a2 = Instance.new("Attachment")
		a2.Name = socketName .. "_A1"
		a2.CFrame = joint.C1
		a2.Parent = joint.Part1
	end

	socket.Parent = joint.Parent

	socket.Attachment0 = a1
	socket.Attachment1 = a2

	socket.LimitsEnabled = true
	socket.TwistLimitsEnabled = true

	socket.TwistLowerAngle = -(twistAngleRange / 2)
	socket.TwistUpperAngle = twistAngleRange / 2

	if destroyOld then
		warn('Destroyed old. This might destroy neck Motor6D and kills the player.')
		joint.Part0 = nil
		joint.Part1 = nil
		joint.Enabled = false

		joint:Destroy()
	end

	return socket
end

local function initRagdollFolder()
	if workspace:FindFirstChild("__ragdoll") then return workspace:FindFirstChild("__ragdoll") end
	
	local folder = Instance.new("Folder")
	folder.Name = "__ragdoll"
	folder.Parent = workspace
	
	return folder
end

local function initCollisionGroup()
	if not game.PhysicsService:IsCollisionGroupRegistered("__ragdollColl") then
		game.PhysicsService:RegisterCollisionGroup("__ragdollColl")
		game.PhysicsService:CollisionGroupSetCollidable("Default", "__ragdollColl", true)
		game.PhysicsService:CollisionGroupSetCollidable("__ragdollColl", "__ragdollColl", false)
	end
end

local function getRagdollModel(ragType:Types.RagdollType, src:Model?):Model?
	if not src then return end
	
	if ragType == "DeathBody" then
		return cloneModel(src)
	elseif ragType == "Toggle" then
		return src
	end
end

local function createOrGetCollisionBox(child:BasePart):(Part, Weld)
	if child:FindFirstChild("_collision") and child:FindFirstChild("_collision"):FindFirstChildOfClass("Weld") then
		return child:FindFirstChild("_collision"), child:FindFirstChild("_collision"):FindFirstChildOfClass("Weld")
	end
	
	local collisionBox = Instance.new("Part")
	collisionBox.Size = child.Size * 0.75

	collisionBox.CanCollide = true
	
	collisionBox.Transparency = 1
	collisionBox.CanTouch = false
	collisionBox.CanQuery = false

	collisionBox.CollisionGroup = "__ragdollColl"

	local weld = Instance.new("Weld")

	weld.Part0 = child
	weld.Part1 = collisionBox

	collisionBox.Name = `_collision`
	collisionBox.Parent = child
	weld.Parent = collisionBox
	
	return collisionBox, weld
end

local function tryStoreRagdoll(obj:Types.Ragdoll, id:string)
	if ragdolls[id] then
		error("Ragdoll already exists at key "..id)
	end
	
	ragdolls[id] = obj
end

-- Creates a new ragdoll handler.
function ragdoll.new(Character:Model, DataTable:Types.RagdollProperties)
	assert(Character, "Ragdoll Character is required.")
	assert(typeof(DataTable) == "table", "The .new() method has been updated and its old use has been deprecated. Please use the new format: new(Character:Model, DataTable:RagdollProperties)")
	local self = (setmetatable({}, ragdoll)::unknown)::Types.Ragdoll
	
	self.Character = Character
	self.RemovalTime = DataTable.RemovalTime or 5
	self.CollisionsEnabled = DataTable.CollisionsEnabled or true
	self.DoFadeOnRemovalReached = DataTable.DoFadeOnRemovalReached or true
	self.FadeTime = DataTable.FadeTime or 10
	self.Friction = DataTable.Friction or 0.25
	self.Elasticity = DataTable.Elasticity or 0.7
	self.Density = DataTable.Density or 0.5
	self.Player = DataTable.Player or nil
	self.AutoDestroy = DataTable.AutoDestroy or true
	self.RagdollType = DataTable.RagdollType or "DeathBody"
	self.DebugMode = DataTable.DebugMode or false
	self.TwistAngleRange = DataTable.TwistAngleRange or 45
	
	self._ragdollCache = {}
	self._ragdollGUID = DataTable.ID or HTTPService:GenerateGUID()
	self._ragdolling = false
	
	tryStoreRagdoll(self, self._ragdollGUID)
	
	if Character then
		local Humanoid = Character:WaitForChild("Humanoid", 5)
		if Humanoid then
			Humanoid.BreakJointsOnDeath = false
		end
	end
	
	return self
end

function ragdoll:destroy()
	if ragdolls[self._ragdollGUID] then
		ragdolls[self._ragdollGUID] = nil
	end
	
	table.clear(self)
	setmetatable(self, nil)
end

function ragdoll:debug(msg)
	if self.DebugMode then
		print(`[DEBUG][RagdollModule]: {tostring(msg)}`)
	end
end

-- Sets the Ragdoll type
function ragdoll:setRagdollType(ragdollType:Types.RagdollType)
	if not ragdollType then return false end
	self.RagdollType = ragdollType
	return true
end


function ragdoll:Knockback(hit : BasePart,targetRoot : BasePart,Direction : Vector3,Duration)
	local CharRagdoll = ragdoll.new(hit.Parent, {
		CollisionsEnabled = true,
		RagdollType = "Toggle",
		AutoDestroy = true,
		RemovalTime = Duration,
	})

	CharRagdoll:doRagdoll(true)

	task.delay(Duration or 2,function()
		CharRagdoll:doRagdoll(false)
	end)

	local BodyVelocity = Instance.new("BodyVelocity")

	BodyVelocity.P = 5000
	BodyVelocity.MaxForce = Vector3.new(math.huge,math.huge,math.huge)
	BodyVelocity.Velocity = Direction
	BodyVelocity.Parent = targetRoot
	
	local BodyAngularVelocity = Instance.new("BodyAngularVelocity")
	BodyAngularVelocity.AngularVelocity = Direction
	BodyAngularVelocity.Parent = targetRoot
	
	game.Debris:AddItem(BodyVelocity,0.25)
	game.Debris:AddItem(BodyAngularVelocity,0.2)
end

function ragdoll:Dismember(character: Model, limbName: string)
	for _, obj in ipairs(character:GetDescendants()) do
		if obj:IsA("BallSocketConstraint") then
			if obj.Name:find(limbName:gsub("%s+", "")) then
				obj:Destroy()
			end
		end
	end
end

-- Starts the ragdoll simulation and removes it after the time specified.
function ragdoll:doRagdoll(toggle:boolean):boolean
	local success, err = pcall(function()	
		initCollisionGroup()
		self:debug(initRagdollFolder())
		
		local characterRagdoll = getRagdollModel(self.RagdollType, self.Character)
		self:debug(characterRagdoll)
		
		local characterHumanoid = characterRagdoll:FindFirstChildOfClass("Humanoid")
		self:debug(characterHumanoid)
		
		if self.RagdollType == "Toggle" and toggle then
			
			task.delay(self.RemovalTime or 10, function()
				-- hala ragdolldaysa geri aç
				if self and self:isRagdolling() then
					self:doRagdoll(false)
				end
			end)
			
		end
		
		if characterHumanoid then
			characterHumanoid.PlatformStand = (self.RagdollType == "DeathBody") or (self.RagdollType == "Toggle" and toggle)

			local animator = characterHumanoid:FindFirstChildOfClass("Animator")

			for _, track in ipairs(animator:GetPlayingAnimationTracks()) do
				if track then
					track:Stop()
				end
			end

			warn(self.RagdollType, '--- ragdoll type. If it is "DeathBody" while player suppose to be alive while ragdoll then it might be the cause.')
			
			if self.RagdollType == "DeathBody" then
				characterHumanoid.DisplayDistanceType = Enum.HumanoidDisplayDistanceType.None
				characterHumanoid.BreakJointsOnDeath = false
				characterHumanoid.Health = -math.huge
			elseif self.RagdollType == "Toggle" and toggle == false then
				-- Force Wake Up
				characterHumanoid:ChangeState(Enum.HumanoidStateType.GettingUp)
				print("getting up")

				-- Prevent any flings
				local rootPart = characterRagdoll:FindFirstChild("HumanoidRootPart")
				if rootPart then
					rootPart.AssemblyLinearVelocity = Vector3.zero
					rootPart.AssemblyAngularVelocity = Vector3.zero
				end
			end
		end
		
		--Ragdoll Wind
		local HRP = characterRagdoll:FindFirstChild("HumanoidRootPart")

		self.RagdollWindConnection = RunService.Heartbeat:Connect(function()
			if not HRP then return end

			local velocity = HRP.AssemblyLinearVelocity.Magnitude
			if velocity < 100 then 
				if HRP:FindFirstChild("RagdollWind") then
					HRP.RagdollWind:Destroy()
				end
				return 
			end

			if not HRP:FindFirstChild("RagdollWind") then
				local RagdollFX = Combat.RagdollWind:Clone()
				RagdollFX.Name = "RagdollWind"
				RagdollFX.Parent = HRP
				RagdollFX.CFrame = HRP.CFrame
				Util:Weld(RagdollFX, HRP)
			end
			
		end)
		
		local lastVelocity = {}

		RunService.Heartbeat:Connect(function()
			for _, part in characterRagdoll:GetDescendants() do
				if part:IsA("BasePart") then
					lastVelocity[part] = part.AssemblyLinearVelocity.Magnitude
				end
			end
		end)
		
		for _, child in characterRagdoll:GetChildren() do
			--RagdollSound
			local fallSoundDebounce = false
			
			self.RagdollSoundConnection = HRP.Touched:Connect(function(hit)
				if not self.CollisionsEnabled then return end
				if fallSoundDebounce then return end
				if not hit or not hit:IsA("BasePart") then return end
				if hit.Parent == characterRagdoll then return end

				local currentVelocity = HRP.AssemblyLinearVelocity.Magnitude
				local previousVelocity = lastVelocity[HRP] or 0

				if previousVelocity > 60 and currentVelocity < 15 then
					fallSoundDebounce = true

					local RandomSound = RagdollSoundTable[math.random(1,#RagdollSoundTable)]:Clone()
					RandomSound.Parent = HRP
					RandomSound:Play()

					game.Debris:AddItem(RandomSound, RandomSound.TimeLength)
					
					task.delay(1, function()
						fallSoundDebounce = false
					end)
				end
			end)
			
			if self.CollisionsEnabled then
				if child:IsA("BasePart") then
					local box, weld = createOrGetCollisionBox(child)
					if not self._ragdollCache[child] then
						self._ragdollCache[child] = {}
					end
					
					if self._ragdollCache[child] and not self._ragdollCache[child].OldCollisionGroup then
						self._ragdollCache[child].OldCollisionGroup = child.CollisionGroup
					end
					
					if self.RagdollType == "Toggle" then
						box.CanCollide = toggle
						box.Massless = not toggle
						child.CollisionGroup = (toggle and "__ragdollColl") or self._ragdollCache[child].OldCollisionGroup
					elseif self.RagdollType == "DeathBody" then
						box.CanCollide = true
						box.Massless = false
						child.CollisionGroup = "__ragdollColl"
					end
					
					if self.DebugMode then
						box.Transparency = 0.5
						box.Material = Enum.Material.Plastic
						box.Color = Color3.new(1,0,0)
						
						child.Transparency = 0.5
					end
				end
			end
		end
		
		for _, child in characterRagdoll:GetDescendants() do
			if (child:IsA("LocalScript") or child:IsA("Script") or child:IsA("ForceField")) and self.RagdollType == "DeathBody" then
				child:Destroy()
			end
		end
		
		characterRagdoll.Parent = (self.RagdollType == "DeathBody" and initRagdollFolder()) or characterRagdoll.Parent
		self:debug(characterRagdoll.Parent)
		
		wait()
		
		for _, child in characterRagdoll:GetDescendants() do
			if child:IsA("BasePart") then
				child.CustomPhysicalProperties = ((self.RagdollType == "DeathBody" or (self.RagdollType == "Toggle" and toggle)) 
					and PhysicalProperties.new(self.Density, self.Friction, self.Elasticity))
					or nil

				if self.RagdollType == "DeathBody" then
					child.CanQuery = false
					child.CanTouch = false
				end
				
				if self.Player and RunService:IsServer() then
					if (self.RagdollType == "Toggle" and toggle) or self.RagdollType == "DeathBody" then
						child:SetNetworkOwner(nil)
					else
						child:SetNetworkOwnershipAuto()
						if self.RagdollWindConnection then
							self.RagdollWindConnection:Disconnect()
							self.RagdollWindConnection = nil
						end
						
						if self.RagdollSoundConnection then
							self.RagdollSoundConnection:Disconnect()
							self.RagdollSoundConnection = nil
						end
					end
				end
			end
			
			if child:IsA("Motor6D") then
				if self.RagdollType == "Toggle" and self._ragdollCache[child] then
					local cache = self._ragdollCache[child]
					
					self._ragdollCache[child].Motor.Enabled = not toggle
					self._ragdollCache[child].BallSocket.Enabled = toggle

					if cache.BallSocket then
						if toggle then
							cache.BallSocket.Enabled = true
						else
							local socket = cache.BallSocket

							local a0 = socket.Attachment0
							local a1 = socket.Attachment1

							socket:Destroy()

							if a0 then
								a0:Destroy()
							end

							if a1 then
								a1:Destroy()
							end

							cache.BallSocket = nil
						end
					end
					
					
					continue
				end

				local ball = join(child, self.TwistAngleRange)
				
				self:debug(child)
				self:debug(ball)
				
				if self.RagdollType == "DeathBody" then
					child.Enabled = false
					ball.Enabled = true
				else
					if not self._ragdollCache[child] then
						self._ragdollCache[child] = {}
					end

					if ball and child then
						self._ragdollCache[child].Motor = child
						self._ragdollCache[child].BallSocket = ball
					end

					child.Enabled = not toggle
					ball.Enabled = toggle
				end
			end
		end
		
		if self.RagdollType == "DeathBody" then
			local doFade, fadeTime = self.DoFadeOnRemovalReached, self.FadeTime -- after cleanup these are nil
			
			task.delay(self.RemovalTime, function()
				if doFade then
					for _, child in characterRagdoll:GetDescendants() do
						if child:IsA("BasePart") or child:IsA("Decal") or child:IsA("Texture") then
							TweenService:Create(child, TweenInfo.new(fadeTime, Enum.EasingStyle.Linear), {
								Transparency = 1
							}):Play()
						end
					end
					
					game.Debris:AddItem(characterRagdoll, fadeTime)
				else
					game.Debris:AddItem(characterRagdoll, 0)
				end
			end)
			
			wait()
			
			characterRagdoll.PrimaryPart.AssemblyLinearVelocity = self.Character.PrimaryPart.AssemblyLinearVelocity
			characterRagdoll.PrimaryPart.AssemblyAngularVelocity = self.Character.PrimaryPart.AssemblyAngularVelocity
			
			self:debug(characterRagdoll.PrimaryPart.AssemblyLinearVelocity)
			self:debug(characterRagdoll.PrimaryPart.AssemblyAngularVelocity)

			local tag = Instance.new("ObjectValue")
			tag.Value = characterHumanoid
			tag.Name = "_ragdoll"

			tag.Parent = self.Character

			game.Debris:AddItem(tag, 3)
		end
	end)
	
	if success then
		self._ragdolling = (self.RagdollType == "DeathBody" and true) or self.RagdollType == "Toggle" and toggle
	end
	
	if self.RagdollType == "DeathBody" then
		for i,v in self.Character:GetDescendants() do
			if v:IsA("BasePart") or v:IsA("Texture") or v:IsA("Decal") then
				v.Transparency = 1
			end

			if v:IsA("BasePart") then
				v.CanCollide = false
				v.CanTouch = false
				v.CanQuery = false
				v.Anchored = true
			end

			if v:IsA("ForceField") then
				v:Destroy()
			end
		end
	end
	
	self:debug(success)
	self:debug(err)
	
	if self.AutoDestroy and self.RagdollType == "DeathBody" then
		self:destroy()
	end
	
	return success, err
end

function ragdoll:isRagdolling()
	return self._ragdolling == true
end

function ragdoll.getRagdoll(id:string)
	return ragdolls[id] or false
end

-- Deletes all the ragdolls inside the ragdoll folder.
function ragdoll.clearAll()
	initRagdollFolder():ClearAllChildren()
end

return ragdoll

I have read through another post and it said that if you got RequiresNeck on and destroy the Motor6D of the player’s neck then it will kills the player. You might want to check if player’s neck Motor6D got destroys and if RequiresNeck property is true in Humanoid while playing the game.

1 Like

Hii.. Sorry for the sudden disappearance, i went to vacation, I did this when I came back, just had it stuck in my mind

function ragdoll.new(Character:Model, DataTable:Types.RagdollProperties)
	assert(Character, "Ragdoll Character is required.")
	assert(typeof(DataTable) == "table", "The .new() method has been updated and its old use has been deprecated. Please use the new format: new(Character:Model, DataTable:RagdollProperties)")
	local self = (setmetatable({}, ragdoll)::unknown)::Types.Ragdoll
	
	self.Character = Character
	self.RemovalTime = DataTable.RemovalTime or 5
	self.CollisionsEnabled = DataTable.CollisionsEnabled or true
	self.DoFadeOnRemovalReached = DataTable.DoFadeOnRemovalReached or true
	self.FadeTime = DataTable.FadeTime or 10
	self.Friction = DataTable.Friction or 0.25
	self.Elasticity = DataTable.Elasticity or 0.7
	self.Density = DataTable.Density or 0.5
	self.Player = DataTable.Player or nil
	self.AutoDestroy = DataTable.AutoDestroy or true
	self.RagdollType = DataTable.RagdollType or "DeathBody"
	self.DebugMode = DataTable.DebugMode or false
	self.TwistAngleRange = DataTable.TwistAngleRange or 45
	
	self._ragdollCache = {}
	self._ragdollGUID = DataTable.ID or HTTPService:GenerateGUID()
	self._ragdolling = false
	
	tryStoreRagdoll(self, self._ragdollGUID)
	
	if Character then
		local Humanoid = Character:WaitForChild("Humanoid", 5)
		if Humanoid then
			Humanoid.RequiresNeck = false
			Humanoid.BreakJointsOnDeath = false
		end
	end
	
	return self
end

I just added “Humanoid.BreakJointsOnDeath = false” and that seemed to fix the problem good, I think there’s no more dying on ragdoll now, I’ll get back here again if something happens

1 Like