Hi developers,
I recently discovered that my ragdoll script, which used to work does not do its job now the way it was intended to.
Basically, my problem is that I cannot change the player’s HumanoidStateType to Physics at all. It just stays Enum.HumanoidStateType.Running.
Here’s a picture showing when the console prints that it has switched to ragdoll and what state the HumanoidStateType is in:
Here’s my code:
local uis = game:GetService("UserInputService")
local status = "unragdoll"
local originstatetype = game.Players.LocalPlayer.Character:WaitForChild("Humanoid").GetState(game.Players.LocalPlayer.Character:WaitForChild("Humanoid"))
print(originstatetype)
uis.InputBegan:Connect(function(inputobject)
if inputobject.KeyCode == Enum.KeyCode.R then
if status == "unragdoll" then
status = "ragdoll"
game.ReplicatedStorage.TestRagdoll:FireServer("Ragdoll", game.Players.LocalPlayer.Character)
local hum = game.Players.LocalPlayer.Character:FindFirstChildOfClass("Humanoid")
--hum:SetStateEnabled(Enum.HumanoidStateType.Running, false)
--hum:SetStateEnabled(Enum.HumanoidStateType.RunningNoPhysics, false)
--hum:SetStateEnabled(Enum.HumanoidStateType.FallingDown, false)
--hum:SetStateEnabled(Enum.HumanoidStateType.Climbing, false)
hum:ChangeState(Enum.HumanoidStateType.Physics)
print("ragdoll;",hum:GetState())
elseif status == "ragdoll" then
status = "unragdoll"
game.ReplicatedStorage.TestRagdoll:FireServer("Unragdoll", game.Players.LocalPlayer.Character)
local hum = game.Players.LocalPlayer.Character:FindFirstChildOfClass("Humanoid")
hum:SetStateEnabled(Enum.HumanoidStateType.Ragdoll, false)
hum:SetStateEnabled(Enum.HumanoidStateType.FallingDown, false)
hum:SetStateEnabled(Enum.HumanoidStateType.Climbing, false)
hum:ChangeState(Enum.HumanoidStateType.Running)
end
end
end)
Thank you in advance for your replies!