Hello, guys. I’m working on a knock/carry/execute system, so basically when player’s health get lowered to zero, he gets knocked and someone can pick them up or finish. I’m using Echo Reaper’s Ragdoll Module in the knocked state, and when player gets knocked, I swap their humanoid state type to phyiscs and enable the ragdoll. But apparently ragdoll gets enabled and state is not changing. The following script located inside player’s character.
local PartsToRestore = {}
Humanoid.HealthChanged:Connect(function()
if Humanoid.Health <= 1 then
StatusManager:Create(Character,"Knocked")
Ragdoller:Set(Humanoid,true)
Humanoid:ChangeState(Enum.HumanoidStateType.Physics)
end
end)
CharacterEvents.Carry.OnServerEvent:Connect(function(PlayerWhoCasted)
local EnemyCharacter = PlayerWhoCasted.Character
if not IsCharacter(EnemyCharacter) then
return
end
local EnemyRootPart = EnemyCharacter:FindFirstChild("HumanoidRootPart")
local HumanoidRootPart = Character:FindFirstChild("HumanoidRootPart")
if PlayerWhoCasted == Player then
if HumanoidRootPart:FindFirstChild("CarryWeld") then
HumanoidRootPart:FindFirstChild("CarryWeld"):Destroy()
return
end
end
if StatusManager:Has(Character,"Knocked") and not StatusManager:Has(Character,"Carried") and not StatusManager:Has(EnemyCharacter,"Carried","Stunned","Knocked") then
StatusManager:Create(Character,"Carried")
StatusManager:Remove(Character,"Knocked")
Humanoid:ChangeState(Enum.HumanoidStateType.None)
Ragdoller:Set(Humanoid,false)
for i,v in pairs(Character:GetDescendants()) do
if v:IsA("BasePart") then
PartsToRestore[v] = v.CollisionGroup
v.CollisionGroup = "Carried"
end
end
local PrimaryWeld = Instance.new("Weld",EnemyRootPart)
PrimaryWeld.Name = "CarryWeld"
PrimaryWeld.Part0 = EnemyRootPart
PrimaryWeld.Part1 = HumanoidRootPart
PrimaryWeld.C0 = CFrame.new(0,2,1.2)
PrimaryWeld.Destroying:Connect(function()
for i,v in pairs(PartsToRestore) do
i.CollisionGroup = v
end
Ragdoller:Set(Humanoid,true)
Humanoid:ChangeState(Enum.HumanoidStateType.Physics)
StatusManager:Create(Character,"Knocked")
StatusManager:Remove(Character,"Carried")
end)
end
end)
The result, when player gets knocked:
GetState prints out Enum.HumanoidStateType.Running