Well, I’m having a problem with my script. I disabled all the states that I don’t want in the ragdoll function, but it still keeps returning to the GettingUp
state, even though this state is disabled.
Ragdoll Function:
function RagdollModule:Ragdoll(Character: Model)
if not Character:GetAttribute("Ragdoll") then
local IsNpc = Players:GetPlayerFromCharacter(Character) == nil
local Humanoid = Character:FindFirstChildWhichIsA("Humanoid")
if not Humanoid then return end
for _, Animation in Humanoid:GetPlayingAnimationTracks() do
Animation:Stop()
end
Character:SetAttribute("Ragdoll", true)
Humanoid.BreakJointsOnDeath = false
Humanoid.AutoRotate = false
Humanoid.RequiresNeck = true
if Character:GetAttribute("CanMove") then
Humanoid.WalkSpeed = 0
Humanoid.JumpPower = 0
end
Humanoid:SetStateEnabled(Enum.HumanoidStateType.Ragdoll, true)
Humanoid:SetStateEnabled(Enum.HumanoidStateType.Jumping, false) -->> Disabled
Humanoid:SetStateEnabled(Enum.HumanoidStateType.Running, false) -->> Disabled
Humanoid:SetStateEnabled(Enum.HumanoidStateType.GettingUp, false) -->> Disabled
Character:FindFirstChild("HumanoidRootPart").CanCollide = false
if IsNpc then
local function PushCharacter()
Humanoid:ChangeState(Enum.HumanoidStateType.Ragdoll)
Humanoid:SetStateEnabled(Enum.HumanoidStateType.GettingUp, false)
Character.PrimaryPart:ApplyImpulse(-Character.PrimaryPart.CFrame.LookVector*200)
end
PushCharacter()
end
self:ReplaceJoints(Character)
end
end
unRagdoll Function:
function RagdollModule:unRagdoll(Character : Model)
if Character:GetAttribute("Ragdoll") and (not Character:GetAttribute("Downed") or Character:GetAttribute("BeingCarried")) then
local IsNpc = Players:GetPlayerFromCharacter(Character) == nil
local Humanoid = Character:FindFirstChildWhichIsA("Humanoid")
if not Humanoid then return end
if Humanoid.Health <= 0.1 then return end
self:ResetJoints(Character)
Character:SetAttribute("Ragdoll", false)
Humanoid.AutoRotate = true
Humanoid.RequiresNeck = false
Humanoid:SetStateEnabled(Enum.HumanoidStateType.Ragdoll, false)
Humanoid:SetStateEnabled(Enum.HumanoidStateType.GettingUp, true)
Humanoid:SetStateEnabled(Enum.HumanoidStateType.Jumping, true)
Humanoid:SetStateEnabled(Enum.HumanoidStateType.Running, true)
Character:FindFirstChild("HumanoidRootPart").CanCollide = true
if IsNpc then
if not Character:GetAttribute("BeingCarried") then
Humanoid:ChangeState(Enum.HumanoidStateType.GettingUp)
print(Humanoid:GetState())
end
end
end
end