I was making my own Ragdoll module script. When I test it out, this is what happens. My goal for ragdoll is I want to make the player fall while ragdoll.
Ragdoll Module:
local module = {}
local PhysicsService = game:GetService('PhysicsService')
local ReplicatedStorage = game:GetService('ReplicatedStorage')
local RagdollRemote = ReplicatedStorage.RemoteEvents.Ragdoll
--PhysicsService:RegisterCollisionGroup('PlayerLimbs')
--PhysicsService:CollisionGroupSetCollidable('PlayerLimbs', 'PlayerLimbs', true)
--PhysicsService:CollisionGroupSetCollidable('PlayerLimbs', 'World', true)
--PhysicsService:CollisionGroupSetCollidable('PlayerLimbs', 'Default', true)
module.SetupRagdoll = function(char: Model)
if char:FindFirstChildOfClass('Humanoid') then
--if char:FindFirstChildOfClass('Humanoid').RigType == 'R6' then
--end
local HumanoidRootPartWeld = Instance.new('Weld', char:FindFirstChild('HumanoidRootPart'))
local Humanoid = char:FindFirstChildOfClass('Humanoid')
Humanoid.BreakJointsOnDeath = false
Humanoid.RequiresNeck = false
char:FindFirstChild('HumanoidRootPart').CanCollide = false
HumanoidRootPartWeld.Part0 = HumanoidRootPartWeld.Parent
HumanoidRootPartWeld.Part1 = char:FindFirstChild('Torso') or char:FindFirstChild('UpperTorso')
HumanoidRootPartWeld.Enabled = false
HumanoidRootPartWeld.Name = 'TorsoWeld'
for i, Motors in pairs(char:GetDescendants()) do
if Motors:IsA('Motor6D') then
local Rope = Instance.new('BallSocketConstraint', Motors.Part0)
local Att0, Att1 = Instance.new('Attachment', Motors.Part0), Instance.new('Attachment', Motors.Part1)
Att0.CFrame = Motors.C0
Att1.CFrame = Motors.C1
Rope.Attachment0 = Att0
Rope.Attachment1 = Att1
Rope.Visible = false
Rope.Name = 'RagJoints'
Rope.LimitsEnabled = true
Rope.TwistLimitsEnabled = true
elseif Motors:IsA('BasePart') then
Motors.CollisionGroup = 'PlayerLimbs'
end
end
end
end
module.Action = function(char: Model, ragdoll: boolean)
if char:FindFirstChildOfClass('Humanoid') then
local player = game.Players:GetPlayerFromCharacter(char)
local Humanoid = char:FindFirstChildOfClass('Humanoid')
if ragdoll == true then
Humanoid:UnequipTools()
if char:FindFirstChild('Ragdoll') then
char:FindFirstChild('Ragdoll').Value = true
end
wait()
Humanoid:ChangeState(Enum.HumanoidStateType.Physics)
for i, v: Instance in pairs(char:GetDescendants()) do
if v:IsA('Motor6D') then
v.Enabled = false
elseif v:IsA('RopeConstraint') and v.Name == 'RagJoints' then
v.Enabled = true
elseif v:IsA('Weld') and v.Name == 'TorsoWeld' then
v.Enabled = false
end
end
RagdollRemote:FireClient(player, false)
else
Humanoid:ChangeState(Enum.HumanoidStateType.GettingUp)
if char:FindFirstChild('Ragdoll') then
char:FindFirstChild('Ragdoll').Value = false
end
for i, v in pairs(char:GetDescendants()) do
if v:IsA('Motor6D') then
v.Enabled = true
elseif v:IsA('RopeConstraint') and v.Name == 'RagJoints' then
v.Enabled = false
elseif v:IsA('Weld') and v.Name == 'TorsoWeld' then
v.Enabled = false
end
end
RagdollRemote:FireClient(player, true)
end
end
end
return module
How it works:
--Setting up ragdoll
game.Players.PlayerAdded:Connect(function(player)
local Character = player.Character or player.CharacterAdded:Wait()
RagdollModule.SetupRagdoll(Character)
local Humanoid = Character:WaitForChild('Humanoid')
local Torso = Character.Torso or Character.UpperTorso
local Ragdoll = Instance.new('BoolValue', Character)
Ragdoll.Name = 'Ragdoll'
end)
--Ragdolling unragdolling
local RagdollModule = require(game.ReplicatedStorage.RagdollModule)
part.Touched:Connect(function(hit)
part.Touched:Connect(function(hit)
RagdollModule.Action(hit.Parent, true)
hit.Parent.Ragdoll.Value = true
wait(3)
RagdollModule.Action(hit.Parent, false)
hit.Parent.Ragdoll.Value = false
end)
end)
Here is the video:
If I miss a simple mistake, I’m sorry about that.