- What do you want to achieve?
I want to make an active ragdoll physics. A character that rotate by himself - What is the issue?
Character is rotating with other character that has a animation - What solutions have you tried so far?
I tried searching on youtube, on roblox forum and tried to fix It myself
Video example:
Video of my project:
EDIT:
Sorry I forgot to paste the code
local humanoid = script.Parent:WaitForChild("Humanoid")
local NewCharacter = game.ReplicatedStorage.DeathMan:Clone()
NewCharacter.Parent = script.Parent
humanoid.BreakJointsOnDeath = false
local Ragdolled = false
local OldHealth = humanoid.Health
humanoid.HealthChanged:Connect(function(NewHealth)
if NewHealth < OldHealth and humanoid.Health > 0 then
if not NewCharacter then
NewCharacter = game.ReplicatedStorage.DeathMan:Clone()
NewCharacter.Parent = script.Parent
end
game.ReplicatedStorage.ChangeState:FireClient(game.Players:GetPlayerFromCharacter(script.Parent), Enum.HumanoidStateType.Physics)
if Ragdolled then return end
Ragdolled = true
for index,joint in pairs(humanoid.Parent:GetDescendants()) do
--if joint:IsA("BasePart") then
--joint:SetNetworkOwner(game.Players:GetPlayerFromCharacter(script.Parent))
--end
if joint:IsA("Motor6D") then
--if joint.Parent:FindFirstChildWhichIsA("BallSocketConstraint") then continue end
--if joint.Part0:FindFirstChild("RagdollA1") then continue end
--if joint.Part1:FindFirstChild("RagdollA2") then continue end
local socket = Instance.new("BallSocketConstraint")
local a1 = Instance.new("Attachment")
local a2 = Instance.new("Attachment")
a1.Name = "RagdollA1"
a2.Name = "RagdollA2"
a1.Parent = joint.Part0
a2.Parent = joint.Part1
socket.Parent = joint.Parent
socket.Attachment0 = a1
socket.Attachment1 = a2
a1.CFrame = joint.C0
a2.CFrame = joint.C1
socket.LimitsEnabled = true
socket.TwistLimitsEnabled = false
joint.Enabled = false
end
end
for _, joint in pairs(NewCharacter:GetDescendants()) do
if joint:IsA("Motor6D") then
joint.Enabled = true
end
end
local Att2
for _, limb in pairs(script.Parent:GetChildren()) do
if limb:IsA("BasePart") then
if limb:FindFirstChild("AlignOrientation") then continue end
if limb:FindFirstChild("Attachment") then continue end
if limb.Name ==" Torso" then continue end
if limb.Name == "HumanoidRootPart" then continue end
local AlignOrientation = Instance.new("AlignOrientation", limb)
AlignOrientation.MaxTorque = 1000
AlignOrientation.Responsiveness = 1000
local Att = Instance.new("Attachment", limb)
AlignOrientation.Attachment0 = Att
Att2 = NewCharacter:FindFirstChild(limb.Name):FindFirstChild("Att2")
if Att2 then
AlignOrientation.Attachment1 = Att2
end
end
end
else
if not Ragdolled then return end
--NewCharacter:Destroy()
game.ReplicatedStorage.ChangeState:FireClient(game.Players:GetPlayerFromCharacter(script.Parent), Enum.HumanoidStateType.GettingUp)
Ragdolled = false
for _, join in pairs(script.Parent:GetDescendants()) do
if join:IsA("Motor6D") then
join.Enabled = true
end
if join.Name == "Attachment" then
join:Destroy()
end
end
for _, join in pairs(script.Parent:GetDescendants()) do
if join:IsA("AlignOrientation") then
join:Destroy()
end
end
end
OldHealth = NewHealth
end)
humanoid.Died:Connect(function()
--NewCharacter:Destroy()
for _, join in pairs(script.Parent:GetDescendants()) do
if join:IsA("Motor6D") then
if not join.Parent:FindFirstChildWhichIsA("BallSocketConstraint") then continue end
join.Parent:FindFirstChildOfClass("BallSocketConstraint").Attachment0:Destroy()
join.Parent:FindFirstChildOfClass("BallSocketConstraint").Attachment1:Destroy()
join.Parent:FindFirstChildOfClass("BallSocketConstraint"):Destroy()
end
end
for _, join in pairs(script.Parent:GetDescendants()) do
if join:IsA("AlignOrientation") then
join:Destroy()
end
end
for index,joint in pairs(humanoid.Parent:GetDescendants()) do
if joint:IsA("Motor6D") then
local socket = Instance.new("BallSocketConstraint")
local a1 = Instance.new("Attachment")
local a2 = Instance.new("Attachment")
a1.Parent = joint.Part0
a2.Parent = joint.Part1
socket.Parent = joint.Parent
socket.Attachment0 = a1
socket.Attachment1 = a2
a1.CFrame = joint.C0
a2.CFrame = joint.C1
socket.LimitsEnabled = true
socket.TwistLimitsEnabled = true
joint:Destroy()
end
end
end)