Un-Ragdoll Flinging Issue

Hey Im having issues with a ragdoll system i found. Everything works the player ragdolls just fine but when it comes to unragdolling the player it does this roblox fling thing which is annoying and testers have complained it interferes with my games combat

Ive done some testing and its definitely a platform stand issue but in this case I want to use platform stand to stop the user from walking and jumping

any help?

local PhysicsService = game:GetService("PhysicsService")
local Players = game:GetService("Players")
local ServerStorage = game:GetService("ServerStorage")
local CollectionService = game:GetService("CollectionService")
local ReplicatedStorage = game:GetService("ReplicatedStorage")

local UserStateMachine = require(ServerStorage.Modules.Manager.UserStateMachine)
local Ragdoll = {}

local JointPositons = {
	Neck = {
		UpperAngle = 40,
		TwistLowerAngle = -45, 
		TwistUpperAngle = 40
	},
	Shoulder = {
		UpperAngle = 110, 
		TwistLowerAngle = -85, 
		TwistUpperAngle = 85
	},
	Hip = {
		UpperAngle = 40, 
		TwistLowerAngle = -90, 
		TwistUpperAngle = 40
	}
}


local function CreateJoints(Character, JointData)
	local Attachment0 = Instance.new("Attachment")
	Attachment0.Name = "BallAttachment"
	Attachment0.CFrame = JointData.CFrameAttachment0
	Attachment0.Parent = Character.Torso
	
	local Attachment1 = Instance.new("Attachment")
	Attachment1.Name = "BallAttachment"
	Attachment1.CFrame = JointData.CFrameAttachment1
	Attachment1.Parent = JointData.MainBodyPart
	
	local BallSocket = Instance.new("BallSocketConstraint")
	BallSocket.Attachment0 = Attachment0
	BallSocket.Attachment1 = Attachment1
	BallSocket.Name = JointData.GlueName
	BallSocket.LimitsEnabled = true;
	
	if JointPositons[JointData.JointType] then
		local SocketData = JointPositons[JointData.JointType]
		BallSocket.UpperAngle = SocketData.UpperAngle
		BallSocket.TwistLowerAngle = SocketData.TwistLowerAngle
		BallSocket.TwistUpperAngle = SocketData.TwistUpperAngle
	end
	
	BallSocket.Parent = Character.Torso
	
	local Collider = Instance.new("Part")
	Collider.Name = "Collider"
	Collider.Size = JointData.MainBodyPart.Size * 0.7 
	Collider.Shape = "Block"
	Collider.CanCollide = false
	Collider.CanQuery = false
	Collider.CanTouch = false
	Collider.Massless = true
	Collider.TopSurface = "Smooth"
	Collider.BottomSurface = "Smooth"
	Collider.formFactor = "Symmetric"
	Collider.Transparency = 1
	Collider.Anchored = false
	Collider.Parent = Character.RagdollColliders
	
	local Weld = Instance.new("Weld")
	Weld.Part0 = JointData.MainBodyPart
	Weld.Part1 = Collider
	Weld.C0 = CFrame.new(0,-0.2,0) * CFrame.fromEulerAnglesXYZ(0, 0, math.pi/2)
	Weld.Parent = Collider	
end

function Ragdoll:Setup(Character)
	local Humanoid = Character.Humanoid
	
	local RagdollColliders = Instance.new("Folder")
	RagdollColliders.Name = "RagdollColliders"
	RagdollColliders.Parent = Character
	
	CreateJoints(Character, {
		MainBodyPart = Character["Left Leg"],
		CFrameAttachment0 = CFrame.new(-0.5, -1, 0, -0, -0, -1, 0, 1, 0, 1, 0, 0),
		CFrameAttachment1 = CFrame.new(-0, 1, 0, -0, -0, -1, 0, 1, 0, 1, 0, 0),
		GlueName = "Left Hip",
		JointType = "Hip"
	})	
	
	CreateJoints(Character, {
		MainBodyPart = Character["Right Leg"],
		CFrameAttachment0 = CFrame.new(0.5, -1, 0, 0, 0, 1, 0, 1, 0, -1, -0, -0),
		CFrameAttachment1 = CFrame.new(0, 1, 0, 0, 0, 1, 0, 1, 0, -1, -0, -0),
		GlueName = "Right Hip",
		JointType = "Hip"
	})
	
	CreateJoints(Character, {
		MainBodyPart = Character["Right Arm"],
		CFrameAttachment0 = CFrame.new(1.5, 0.5, 0, 0, 0, 1, 0, 1, 0, -1, 0, 0),
		CFrameAttachment1 = CFrame.new(0, 0.5, 0, 0, 0, 1, 0, 1, 0, -1, 0, 0),
		GlueName = "Right Shoulder",
		JointType = "Shoulder"	
	})
	
	CreateJoints(Character, {
		MainBodyPart = Character["Left Arm"],
		CFrameAttachment0 = CFrame.new(-1.5, 0.5, 0, 0, 0, -1, 0, 1, 0, 1, 0, 0),
		CFrameAttachment1 = CFrame.new(0, 0.5, 0, 0, 0, -1, 0, 1, 0, 1, 0, 0),
		GlueName = "Left Shoulder",
		JointType = "Shoulder"
	})	
end

function Ragdoll.Start(Character : Model, Duration : number)
	if not Character or not Character.PrimaryPart then return end
	
	local Player = Players:GetPlayerFromCharacter(Character)
	
	local Humanoid = Character.Humanoid
	Humanoid:SetStateEnabled(Enum.HumanoidStateType.FallingDown, false)
	Humanoid:SetStateEnabled(Enum.HumanoidStateType.GettingUp, false)
	Humanoid:SetStateEnabled(Enum.HumanoidStateType.Ragdoll, true)
	Humanoid:SetStateEnabled(Enum.HumanoidStateType.Physics, true)
	
	Character:SetAttribute("Ragdolled",true)
	
	Humanoid.AutoRotate = false
	Humanoid.PlatformStand = true
	--Humanoid.WalkSpeed = 0
	--Humanoid.JumpHeight = 0
	Humanoid.Jump = false
	
	Character.Torso["Right Hip"].Enabled = false
	Character.Torso["Right Shoulder"].Enabled = false
	Character.Torso["Left Hip"].Enabled = false
	Character.Torso["Left Shoulder"].Enabled = false
	
	for _, v in ipairs(Character.RagdollColliders:GetChildren()) do
		v.CanCollide = true
	end
	
	Character.HumanoidRootPart:ApplyAngularImpulse(Vector3.new(-90, 0, 0))
	
	if Duration then 
		task.delay(Duration, function()
			Ragdoll.Stop(Character)
		end)
	end
end

function Ragdoll.Stop(Character : Model, bypass)
	local DisableRagdoll = true
	
	local player = Players:GetPlayerFromCharacter(Character)
	
	if Character and player then 
		local states = UserStateMachine:getStates(player)
		if states["Downed"] and not bypass then 
			DisableRagdoll = false
		end
	end
	
	
	if DisableRagdoll then
		local Humanoid = Character.Humanoid :: Humanoid
		local rootPart = Character:FindFirstChild("HumanoidRootPart")
		
		
		for _, v in pairs(Character.RagdollColliders:GetChildren()) do
			v.CanCollide = false
		end
		
		for _, child in pairs(rootPart:GetChildren()) do
			if child:IsA("BodyVelocity") or child:IsA("BodyPosition") or child:IsA("BodyAngularVelocity") or 
				child:IsA("LinearVelocity") or child:IsA("AlignPosition") or child:IsA("VectorForce") then
				child:Destroy()
			end
		end
		
		rootPart.AssemblyLinearVelocity = Vector3.new(0,0,0)
		rootPart.AssemblyAngularVelocity = Vector3.new(0,0,0)
		

		Character.Torso["Right Hip"].Enabled = true
		Character.Torso["Right Shoulder"].Enabled = true
		Character.Torso["Left Hip"].Enabled = true
		Character.Torso["Left Shoulder"].Enabled = true

		Character:SetAttribute("Ragdolled", false)

		Humanoid:SetStateEnabled(Enum.HumanoidStateType.FallingDown, false)
		Humanoid:SetStateEnabled(Enum.HumanoidStateType.GettingUp, true)
		Humanoid:SetStateEnabled(Enum.HumanoidStateType.Ragdoll, false)
		Humanoid:SetStateEnabled(Enum.HumanoidStateType.Physics, false)
		
		
		Humanoid.AutoRotate = true
		Humanoid.PlatformStand = false
		
	end
end

function Ragdoll:CarriedEnabled(Character)
	local Humanoid = Character.Humanoid

	for _, v in pairs(Character.RagdollColliders:GetChildren()) do
		v.CanCollide = false
	end

	Character.Torso["Right Hip"].Enabled = true
	Character.Torso["Right Shoulder"].Enabled = true
	Character.Torso["Left Hip"].Enabled = true
	Character.Torso["Left Shoulder"].Enabled = true
end

return Ragdoll

Try calling Humanoid:ChangeState(Enum.HumanoidStateType.GettingUp) when your character unragdoll.

Humanoid:SetStateEnabled(Enum.HumanoidStateType.FallingDown, false)
Humanoid:SetStateEnabled(Enum.HumanoidStateType.GettingUp, true)
Humanoid:SetStateEnabled(Enum.HumanoidStateType.Ragdoll, false)
Humanoid:SetStateEnabled(Enum.HumanoidStateType.Physics, false)
Humanoid:ChangeState(Enum.HumanoidStateType.GettingUp)

What if you add something the Y of the root part when you unragdoll

tried this and it didnt work for some reason their still getting flinged