-
**What do you want to achieve?**I want that when a player presses a button, his character become ragdoll, but he can move while ragdoll
-
What is the issue? I can’t move while ragdoll
-
What solutions have you tried so far? Ragdoll module for all character - #22 by Ofc_Infinitybad The problem is that i cannot move when i’m ragdoll
So basically this is my client script
script.Parent.MouseButton1Click:Connect(function()
local plr = game.Players.LocalPlayer
plr.Character.Humanoid:ChangeState(Enum.HumanoidStateType.Physics)
game.ReplicatedStorage.Ragdoll:FireServer(plr)
end)
and this is the server script
game.ReplicatedStorage.Ragdoll.OnServerEvent:Connect(function(plr)
local RagdollModule = require(game.ReplicatedStorage.RagdollModule)
RagdollModule:RigPlayer(plr.Character)
end)
And this is the module script
local mod = {}
function mod:RigPlayer(Character : Model)
local hum : Humanoid? = Character:WaitForChild("Humanoid")
local hrp : BasePart? = Character:WaitForChild("HumanoidRootPart")
local db = false
assert(hum,Character.Name.." isnt a humanoid")
hum.BreakJointsOnDeath = false
local WeldConstranint = Instance.new("WeldConstraint",hrp)
for _,v in pairs(Character:GetDescendants()) do
if v:IsA("Motor6D") then
local BallSocket = Instance.new("BallSocketConstraint",v.Part0)
BallSocket.Name = "BC"
if v.Part1 ~= Character.PrimaryPart and v.Part0 ~= Character.PrimaryPart then
v.Part1.CanCollide = false
v.Part0.CanCollide = false
end
local att1 = Instance.new("Attachment",v.Part0) att1.Name = "AttRag"
local att2 = Instance.new("Attachment",v.Part1) att1.Name = "AttRag"
att2.Position = v.C1.Position
att1.WorldPosition= att2.WorldPosition
BallSocket.LimitsEnabled = true
BallSocket.TwistLimitsEnabled = true
BallSocket.Attachment0 = att1
BallSocket.Attachment1 = att2
if v.Part0 == Character.PrimaryPart and v.Part1 ~= Character.PrimaryPart then
WeldConstranint.Part0 = Character.PrimaryPart
WeldConstranint.Part1 = v.Part1
WeldConstranint.Enabled = false
end
end
end
hum:GetPropertyChangedSignal("Health"):Connect(function()
if hum.Health <= 0 and db == false then
db = true
for _, v in ipairs(Character:GetDescendants()) do
if v:IsA("Motor6D") then
if v.Part1 ~= Character.PrimaryPart and v.Part0 ~= Character.PrimaryPart then
v.Part1.CanCollide = true
v:Destroy()
else
WeldConstranint.Enabled = true
Character.PrimaryPart.CanCollide = false
end
end
end
end
end)
hum.StateChanged:Connect(function(_,State)
if State == Enum.HumanoidStateType.Physics then
for _, v in ipairs(Character:GetDescendants()) do
if v:IsA("Motor6D") then
if v.Part1 ~= Character.PrimaryPart and v.Part0 ~= Character.PrimaryPart then
v.Part1.CanCollide = true
v.Enabled = false
else
WeldConstranint.Enabled = true
Character.PrimaryPart.CanCollide = false
end
end
end
elseif State == Enum.HumanoidStateType.GettingUp then
for _, v in ipairs(Character:GetDescendants()) do
if v:IsA("Motor6D") then
if v.Part1 ~= Character.PrimaryPart and v.Part0 ~= Character.PrimaryPart then
v.Part1.CanCollide = false
v.Enabled = true
else
WeldConstranint.Enabled = false
Character.PrimaryPart.CanCollide = true
end
end
end
end
end)
end
return mod
I also tried to make a script, but it is rly bugged (the character literally fly)
game.ReplicatedStorage.Ragdoll.OnServerEvent:Connect(function(plr)
local character = plr.Character
local humanoid = character:FindFirstChild("Humanoid")
for _, joint in pairs(character:GetDescendants()) do
if joint:isA("Motor6D") and joint.Name ~= "Neck" then
local socket = Instance.new("BallSocketConstraint", joint.Parent)
local a0 = Instance.new("Attachment")
local a1 = Instance.new("Attachment")
socket.Attachment0 = a0
socket.Attachment1 = a1
a0.Parent = joint.Part0
a1.Parent = joint.Part1
a0.CFrame = joint.C0
a1.CFrame = joint.C1
socket.LimitsEnabled = true
socket.TwistLimitsEnabled = true
joint:Destroy()
end
end
end)