Help with ragdoll!

Hi! I require ragdoll but the problem is the ragdoll isn’t working like its suppose to!

local tool=script.Parent
local Debris = game:GetService("Debris") 
local handle=tool:WaitForChild("Handle")
local abilityactivategui=tool:WaitForChild("AbilityActivateButton")
local Info = TweenInfo.new(1)
local Goal = {Color = Color3.new(0.427451, 1, 0.32549)}
local Goal2 = {Color = Color3.new(0.0666667, 0.0666667, 0.0666667)}
local Tween = game.TweenService:Create(abilityactivategui.ImageLabel.outside, TweenInfo.new(0.2), Goal)
local Tween2 = game.TweenService:Create(abilityactivategui.ImageLabel.outside, TweenInfo.new(0.2), Goal2)
tool:WaitForChild("Event").OnServerEvent:Connect(function(plr,mode,target,velocity)
	if mode=="slash" then
		local own = script.Parent.OWNER
		own.Value = plr.Character.Name
		if target:FindFirstChild("Humanoid") then
		else
			return
		end
		if target.Name == own.Value then
 owner
			return
		else
		end
		local slaps = plr.leaderstats.Slices
		local RTG = script.Parent.RagdollTime.Value
		slaps.Value += 1
		local flingvelocity=velocity*5
		local spinvelocity=velocity*0.5
		local multipliervelocity=tool:WaitForChild("Power").Value
		local bv=Instance.new("BodyVelocity")
		bv.Parent=target:WaitForChild("HumanoidRootPart")
		bv.MaxForce=Vector3.new(1e8,1e8,1e8)
		bv.Velocity=flingvelocity+Vector3.new(0,multipliervelocity,0)
		local bav=Instance.new("BodyAngularVelocity")
		bav.Parent=target:WaitForChild("HumanoidRootPart")
		bav.AngularVelocity=flingvelocity+Vector3.new(0,multipliervelocity,0)
		script.Parent.Handle.hit.Enabled = true
		script.Parent.Handle.hit2.Enabled = true
		target.Humanoid:ChangeState'Physics'
		target.Humanoid.PlatformStand = true
		local value = Instance.new("BoolValue")
		value.Name = "SLAPPED"
		value.Value = true
		value.Parent = target
		for index,joint in pairs(target:GetDescendants()) do
			if joint:IsA("Motor6D") then
				local socket = Instance.new("BallSocketConstraint")
				local a1 = Instance.new("Attachment")
				local a2 = Instance.new("Attachment")
				a1.Parent = joint.Part0
				a2.Parent = joint.Part1
				socket.Parent = joint.Parent
				socket.Attachment0 = a1
				socket.Attachment1 = a2
				a1.CFrame = joint.C0
				a2.CFrame = joint.C1
				socket.LimitsEnabled = true
				socket.TwistLimitsEnabled = true
				joint.Enabled = false
			end
		end
		wait(0.1)
		target.Humanoid.Health -= 15
		script.Parent.Handle.hit.Enabled = false
		script.Parent.Handle.hit2.Enabled = false
		local sound=Instance.new("Sound")
		sound.Parent=target:WaitForChild("HumanoidRootPart")
		sound.Volume=3
		sound.SoundId="rbxassetid://9075321955"
		sound:Play()
		wait(tool:WaitForChild("FlightSpeed").Value)
		bv:Destroy()
		bav:Destroy()
		sound:Destroy()
		wait(RTG)
		value:Destroy()
		for index,joint in pairs(target:GetDescendants()) do
			if joint:IsA("Motor6D") then
				target.Humanoid:ChangeState'GettingUp'
				target.Humanoid.PlatformStand = false
				joint.Enabled = true
			end
		end

It is suppose to work like slap battles ragdoll, where they always fall on the ground but sometimes it will float and stand up mid ragdoll.

Hi there,

Wow, what a great way to catch someone’s attention with not just one, or two, but THREE exclamation marks in the post title! By any chance, could you kindly provide some videos of the issue (and possibly the source file itself)? The code is almost like a cryptic puzzle waiting to be deciphered. Thanks!

Whenever i said a video, it just breaks which is really annoying and its rare but often, it only works on players so i can’t exactly show it.