local RagdollModule = {}
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local Players = game:GetService("Players")
local PhysicsService = game:GetService("PhysicsService")
local Events = ReplicatedStorage:WaitForChild("Events")
local RemoteEvent = Events.Ragdoll
local Table = {"Left Shoulder","Right Shoulder","Left Hip","Right Hip","Neck"}
function RagdollModule:Ragdoll(Character : Model, bool : boolean)
local Humanoid : Humanoid = Character.Humanoid
local Player = Players:GetPlayerFromCharacter(Character)
if Character.Humanoid.Health > 0 and (Character:FindFirstChild("Torso") and not Character.Torso.Neck.Enabled) and bool == false then
if Player then
RemoteEvent:FireClient(Player,false)
else
Character.Animate.Disabled = false
Humanoid:SetStateEnabled(Enum.HumanoidStateType.GettingUp,true)
Humanoid:ChangeState(Enum.HumanoidStateType.GettingUp)
end
for _,v : Instance in ipairs(Character:GetDescendants()) do
if v:IsA("Motor6D") then
v.Enabled = true
elseif v:IsA("BallSocketConstraint") then
v.Enabled = false
end
end
else
if Player then
RemoteEvent:FireClient(Player,true)
else
Humanoid:SetStateEnabled(Enum.HumanoidStateType.GettingUp,false)
Humanoid:ChangeState(Enum.HumanoidStateType.Ragdoll)
for _,v in ipairs(Humanoid.Animator:GetPlayingAnimationTracks())do
v:Stop(0)
end
Character.Animate.Disabled = true
end
for _,v : Instance in ipairs(Character:GetDescendants()) do
if v:IsA("Motor6D") and RagdollModule:Check(v.Name)then
v.Enabled = false
elseif v:IsA("BallSocketConstraint") then
v.Enabled = true
end
end
end
return
end
function RagdollModule:Check(Name : string)
if table.find(Table,Name) then
return true
else
return false
end
end
function RagdollModule:Joints(Character : Model)
local Humanoid : Humanoid = Character.Humanoid
Humanoid.BreakJointsOnDeath = false
Humanoid.RequiresNeck = false
for _,v : Instance in ipairs(Character:GetDescendants()) do
if v:IsA("Motor6D") and RagdollModule:Check(v.Name) then
local BallSocketConstraint = Instance.new("BallSocketConstraint")
local Attachment0 = Instance.new("Attachment")
local Attachment1 = Instance.new("Attachment")
Attachment0.CFrame = v.c0
Attachment1.CFrame = v.C1
Attachment0.Parent = v.Part0
Attachment1.Parent = v.Part1
BallSocketConstraint.Attachment0 = Attachment0
BallSocketConstraint.Attachment1 = Attachment1
BallSocketConstraint.LimitsEnabled = true
BallSocketConstraint.TwistLimitsEnabled = true
BallSocketConstraint.Enabled = false
BallSocketConstraint.Parent = v.Parent
elseif v:IsA("BasePart") then
v.CollisionGroup = "RagdollA"
if v.Name == "HumanoidRootPart" then
v.CollisionGroup = "RagdollB"
elseif v.Name == "Head"then
v.CanCollide = true
end
end
end
end
return RagdollModule
I have this issue with the ragdoll script, i figured that when i ragdoll, then reset, i am dead forever. Does anybody know why this is happening? I also figured that when you ragdoll, then die, the server doesnât detect that you are dead.
Most likely a script or setting is preventing the game from triggering the respawn. Usually happens when two rigs with Humanoids in them are welded together.
This is because of platform stand.
To fix this you need find in humanoid find âPlatformStandingâ and inside script make like âHumanoid.PlatformStanding = trueâ.
I had the same issue myself. I did not do anything about NeckRequired to solve it but this script worked for me (In ServerScriptService):
local RUS = game:GetService("RunService")
RUS.Heartbeat:Connect(function()
for i,v in pairs(game.Players:GetPlayers()) do
if v.Character then
if not v.Character:FindFirstChild("HumanoidRootPart") and v:HasAppearanceLoaded() then
v:LoadCharacter()
end
end
end
end)
This code basically just respawns the player when the glitch happens.
Hi, can this system be run only on a client? I am trying to make it so instead of running on the server, each client gets alerted that the npc is ragdolled for a smoother experience.
Yeah, that literally means it is the moduleâs fault. RequiresNeck kills the player if their neck is gone, so if itâs disabled then the player canât die.