Platformstand Flinging Ragdolled Player

Hello, I’m trying to make the player stand up after being ragdolled. However, using platform stand-alone flings the player. Right now I have a hacky method that turns off platform stand and sets the players humrootpart cframe to the cframe it was before platform stand was disabled for .3 seconds.

Product with my hacky method:
https://gyazo.com/47b9d0652fdd1b2feb1f69790a4b20d7
Product without my hacky method:
https://gyazo.com/2e12f65e2f89413c5ba2533b3d910ed7

However, If possible I’d like the player to immediately stand upright.

game.Players.PlayerAdded:Connect(function(plr)
	plr.CharacterAdded:Connect(function(char) 
		local value = char:WaitForChild("PlayerEffects"):WaitForChild("Knocked")
		value.Changed:Connect(function(newVal)
			if newVal == true then
				wait()
				ragdollChar(char)
			elseif newVal == false then
				wait()
				resetChar(char)
			end
		end)
	end)
end)

joints = {} welds = {} fakeLimbs = {}
ragdolling = false

function resetChar(char)
	if ragdolling then
		ragdolling = false
		wait()
		
		for _, this in pairs(joints) do 
			this.Parent = char.Torso -- Add the joints back
		end
		for _, this in pairs(welds) do 
			this:Destroy() -- destroy old welds
		end
		for _, this in pairs(fakeLimbs) do 
			this:Destroy() -- destroy temp parts
		end
		local resetPosition = true
		local humrootCFrame = char.HumanoidRootPart.CFrame
		local function ResetPosition()
			while resetPosition do wait()
				char.HumanoidRootPart.CFrame = humrootCFrame
			end
		end
		char.Humanoid.PlatformStand = false	
		spawn(ResetPosition)
               ---hacky solution
		wait(.3)
		char.Humanoid:ChangeState(Enum.HumanoidStateType.GettingUp)
		resetPosition = false
	end
end

function ragdollChar(char)
	if not ragdolling then
		ragdolling = true 
		char.Humanoid.PlatformStand = true

		local leftArm = char["Left Arm"]
		local rightArm = char["Right Arm"]
		local leftLeg = char["Left Leg"]
		local rightLeg = char["Right Leg"]
		local head = char.Head
		local torso = char.Torso
		local function cloneJoints(character)
			for _,this in ipairs(character.Torso:GetChildren()) do
				if this:isA("Motor6D") and this.Name ~= "Neck" then
					joints[this.Name] = this:Clone()
				end
			end
		end	
		local function createGlue(part0, part1, name)
			local glue = Instance.new("Glue", torso)
			glue.Part0 = part0;glue.Part1 = part1;glue.Name = name
			welds[#welds+1] = glue
			return glue
		end	
		local function createLimb(parent, position, size)
			local limb = Instance.new("Part", parent)
			limb.Position = position;limb.Size = size;limb.Transparency = 1
			fakeLimbs[#fakeLimbs+1] = limb
			return limb
		end
		local function createWeld(parent, p0, p1)
			local weld = Instance.new("Weld", parent)
			weld.Part0 = p0;weld.Part1 = p1;
			weld.C0 = CFrame.new(0,-0.2,0) * CFrame.fromEulerAnglesXYZ(0, 0, math.pi/2)
			welds[#welds+1] = weld
			return weld
		end
		
		cloneJoints(char)
		-- LEFT LEG --
		char.Torso["Left Hip"]:Destroy()
		local glue = createGlue(torso, leftLeg, "Left leg")
		glue.C0 = CFrame.new(-0.5, -1, 0, -0, -0, -1, 0, 1, 0, 1, 0, 0)
		glue.C1 = CFrame.new(-0, 1, 0, -0, -0, -1, 0, 1, 0, 1, 0, 0)
		local fakeLeftLeg = createLimb(leftLeg, Vector3.new(0,999,0), Vector3.new(1.5, 1, 1))
		createWeld(fakeLeftLeg, leftLeg, fakeLeftLeg)
		-- RIGHT LEG --
		char.Torso["Right Hip"]:destroy()
		local glue = createGlue(torso, rightLeg, "Right leg")
		glue.C0 = CFrame.new(0.5, -1, 0, 0, 0, 1, 0, 1, 0, -1, -0, -0)
		glue.C1 = CFrame.new(0, 1, 0, 0, 0, 1, 0, 1, 0, -1, -0, -0)
		local fakeRightLeg = createLimb(rightLeg, Vector3.new(0,999,0), Vector3.new(1.5, 1, 1))
		createWeld(fakeRightLeg, rightLeg, fakeRightLeg)	
		-- RIGHT ARM --
		char.Torso["Right Shoulder"]:destroy()
		local glue = createGlue(torso, rightArm, "Right shoulder")
		glue.C0 = CFrame.new(1.5, 0.5, 0, 0, 0, 1, 0, 1, 0, -1, 0, 0)
		glue.C1 = CFrame.new(0, 0.5, 0, 0, 0, 1, 0, 1, 0, -1, 0, 0)	
		local fakeRightArm = createLimb(rightArm, Vector3.new(0,999,0), Vector3.new(1.8,1,1))
		createWeld(fakeRightArm, rightArm, fakeRightArm)
		-- LEFT ARM --
		char.Torso["Left Shoulder"]:destroy()
		local glue4 = createGlue(torso, leftArm, "Left shoulder")
		glue4.C0 = CFrame.new(-1.5, 0.5, 0, 0, 0, -1, 0, 1, 0, 1, 0, 0)
		glue4.C1 = CFrame.new(0, 0.5, 0, 0, 0, -1, 0, 1, 0, 1, 0, 0)		
		local fakeLeftArm = createLimb(leftArm, Vector3.new(0,999,0), Vector3.new(1.5, 1, 1))	
		createWeld(fakeLeftArm, leftArm, fakeLeftArm)
	end
end
1 Like

Handling the script on the client fixed the issue.

1 Like