How do i fix getting up glitch

heres the video:

ragdoller:

wait()
– not x.Parent:IsA(“Accessory”) or x.Parent.ClassName ~= "Hat
v = script.Parent.V
c = script.Parent.Parent
Humanoid = c.Humanoid
RootJoint = c.HumanoidRootPart.RootJoint
ljp = c.Humanoid.JumpPower
Head = c.Head
walkspeed = c.Humanoid.WalkSpeed
camera = workspace.Camera.CameraSubject
c.Humanoid.BreakJointsOnDeath = false
v.Changed:Connect(function()
if v.Value == true then
c.Humanoid.PlatformStand = true

	for i, x in pairs(c:GetChildren()) do
		if x:IsA("BasePart") or x:IsA("Part") then
			if x.Name ~= "Torso" and x.Name ~= "HumanoidRootPart" then
				local collision = Instance.new("Part",x)
				collision.Name = "collider"
				collision.Transparency = 1
				collision.CFrame = x.CFrame * CFrame.new(0,-.35,0)
				collision.Size = Vector3.new(x.Size.x-.15,x.Size.Y -.8,x.Size.Z-.15)
				local wc = Instance.new("WeldConstraint",collision)
				wc.Part0 = collision
				wc.Part1 = x
			end
			ljp = 0
			walkspeed = 0
			local bs = Instance.new("BallSocketConstraint")
			bs.Parent = c.Torso
			local a0,a1 = Instance.new("Attachment"),Instance.new("Attachment")
			a0.Parent = x
			a0.Axis = Vector3.new(1,0,0)
			a0.SecondaryAxis = Vector3.new(0,1,0)
			a1.Axis = Vector3.new(1,0,0)
			a1.SecondaryAxis = Vector3.new(0,1,0)
			a1.Parent = c.Torso
			bs.Name = x.Name:lower()
			bs.Attachment0 = a0
			a0.Name = "RagdollAttach"
			a1.Name = "RagdollAttach"
			Humanoid.PlatformStand = true
			for _,pee in pairs(script.Parent.Parent.Torso:GetChildren()) do
				if pee:IsA("Motor6D") then
					pee.Enabled = false
				end
			end
			bs.Attachment1 = a1
			if x.Name == "Right Arm" then
				a1.Position = Vector3.new(1, 0.6, 0)
				a0.Position = Vector3.new(0, 1, -0.35)
			elseif x.Name == "Left Arm" then
				a1.Position = Vector3.new(-1, 0.6, 0)
				a0.Position = Vector3.new(0, 1, 0)
			elseif x.Name == "Right Leg" then
				a1.Position = Vector3.new(0.55, -1.05, 0)
				a0.Position = Vector3.new(0, 0.99,0)
			elseif x.Name == "Left Leg" then
				a1.Position = Vector3.new(-0.55, -1.05, 0)
				a0.Position = Vector3.new(0, 0.99, 0)
			elseif x.Name == "Head" then
				bs.LimitsEnabled = true
				bs.TwistLimitsEnabled = true
				a1.Position = Vector3.new(0,1.1,0)
				a0.Position = Vector3.new(0,-.5,0)
			end
		end
	end
elseif v.Value == false then
	local db = game:GetService("Debris")
	walkspeed = 16
	camera = Humanoid
	
	c.Humanoid.PlatformStand = false
	ljp = 50
	for _,pee in pairs(script.Parent.Parent.Torso:GetChildren()) do

		if pee:IsA("Motor6D") then
			pee.Enabled = true
		end
	end
	for i, p in pairs(script.Parent.Parent:GetDescendants()) do
		if p:IsA("Attachment") and p.Name == "RagdollAttach" or p:IsA("BallSocketConstraint") or p.Name == "collider" then
			p:Destroy()
		end
	end

end

end)

also its a script not local script (if you can make a script for local script)

i tried Humanoid:ChangeState and it didn’rt work

i fixed it now my euphoria fan made r6 is don