Instantly put player upright after ragdoll

I decided to repeat the ragdoll system from Slap Battles. I was able to make code that triggers the ragdoll and also exits this state.
But in the process of exiting ragdoll I encountered a small problem.
When on the client I change the state of Humanoid to Getting Up, he rises from the ground with a slight delay and shaking of the limbs of the body.
After a huge number of attempts, I achieved the desired result and possibly eliminated this bug.

Code to use on the client:

local MAX_LENGTH = 900000
local CAMERA = game.Workspace.CurrentCamera
		
local Plr = game.Players.LocalPlayer
		
local Character = Plr.Character
local HumanoidRootPart: BasePart = Character:WaitForChild("HumanoidRootPart")
local Humanoid: Humanoid = Character:WaitForChild("Humanoid")
		
Humanoid.PlatformStand = true

if Humanoid.FloorMaterial ~= Enum.Material.Air or Humanoid.FloorMaterial ~= Enum.Material.Water then

	local UpPos = HumanoidRootPart.Position + Vector3.new(0, 3.5, 0)

	Character:PivotTo(CFrame.new(UpPos))

	UpPos = nil

end	

local StabilizationCFrame = CFrame.new(HumanoidRootPart.Position, Vector3.new(CAMERA.CFrame.LookVector.X * MAX_LENGTH, HumanoidRootPart.Position.Y, CAMERA.CFrame.LookVector.Z * MAX_LENGTH))

local Stabilizer = Instance.new("BodyGyro")
Stabilizer.CFrame = StabilizationCFrame
Stabilizer.P = 1000000
Stabilizer.D = 500
Stabilizer.MaxTorque = Vector3.new(10000, 0, 10000)
Stabilizer.Name = "StabilizerForce"
Stabilizer.Parent = HumanoidRootPart
game.Debris:AddItem(Stabilizer, 0)

repeat

	for _, Body_Part in pairs(Character:GetDescendants()) do

		if Body_Part:IsA("BasePart") then

			Body_Part.CanCollide = false

		end

	end

	task.wait()

until not HumanoidRootPart:FindFirstChild(Stabilizer.Name)

Humanoid.PlatformStand = false
Humanoid:SetStateEnabled(Enum.HumanoidStateType.GettingUp, true)
Humanoid:ChangeState(Enum.HumanoidStateType.GettingUp)
Humanoid:SetStateEnabled(Enum.HumanoidStateType.Seated, true)

Enable it after the player has left ragdoll on the server!

1 Like

At the end you are setting Platform stand to true again. I think that might be the Problem, as you want the Player to stand up, you need to disable platform stand

I created a new topic where I explained in detail my own Ragdoll system like in Slap Battles!

In short, the solution is to place the character perpendicular to the ground instantly after leaving Ragdoll. I implemented this by specifying the CFrame parameter of the HumanoidRootPart without Rotation, whose Position was calculated using Raycast, lowered down.

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.