Ragdoll character not jumping

This is a project me and @korbykobs are working on.

Correct:

Broken:

Here is the script:

local ragdoll = false

script.Parent.UpperTorso.Touched:Connect(function(part)
	local living = {}
	for i,v in pairs(game.Workspace:GetDescendants()) do
		if v:IsA("Humanoid") then
			table.insert(living,1,v.Parent)
		end
	end
	table.remove(living,table.find(living,script.Parent))
	for i,v in pairs(living) do
		if part:IsDescendantOf(v) then
			v.Humanoid:TakeDamage(v.Humanoid.MaxHealth)
		end
	end
end)

while wait() do
	if ragdoll == false then
		local closestDistance = 0
		local closestDistanceCharacter = nil
		local living = {}
		for i,v in pairs(game.Workspace:GetDescendants()) do
			if v:IsA("Humanoid") then
				table.insert(living,1,v.Parent)
			end
		end
		table.remove(living,table.find(living,script.Parent))
		for i,v in pairs(living) do
			if script.Parent.PrimaryPart ~= nil and v.PrimaryPart ~= nil and v.Humanoid.Health ~= 0 then
				local distance = (script.Parent.PrimaryPart.Position - v.PrimaryPart.Position).Magnitude
				if closestDistanceCharacter == nil or distance > closestDistance then
					closestDistance = distance
					closestDistanceCharacter = v
				end
			end
		end
		if closestDistanceCharacter ~= nil and closestDistanceCharacter.Humanoid.Health ~= 0 then
			script.Parent.Humanoid:MoveTo(closestDistanceCharacter.PrimaryPart.Position) 
			if closestDistance <= 25 then
				script.Parent.Humanoid.HipHeight = 0
				script.Parent.Humanoid.PlatformStand = true
				for i,v in pairs(script.Parent:GetDescendants()) do
					if v:IsA("Motor6D") and v.Parent ~= script.Parent.HumanoidRootPart then
						v.Enabled = false
					end
					if v:IsA("Constraint") then
						v.Enabled = true
					end
				end
				script.Parent.PrimaryPart.Velocity = (script.Parent.PrimaryPart.CFrame.LookVector * 75) + Vector3.new(0,75,0)
				ragdoll = true
			end
		end
	else
		wait(5)
		script.Parent.Humanoid.HipHeight = 3
		script.Parent.Humanoid.PlatformStand = false
		for i,v in pairs(script.Parent:GetDescendants()) do
			if v:IsA("Motor6D") and v.Parent ~= script.Parent.HumanoidRootPart then
				v.Enabled = true
			end
			if v:IsA("Constraint") then
				v.Enabled = false
			end
		end
		ragdoll = false
	end
end

It is supposed to leap at someone in range, but it just tends to flop over without leaping.

Is it because you are dropping the HipHeight to 0 and the humanoid is getting stuck in the ground?

1 Like

Without that, it starts floating up into the air. Could this be due to the way I have rigged it?

I don’t’ have a great knowledge of rigging and the HipHeight property, but from what I understand it’s the position of the bottom of the Humanoid’s RootPart.
Try setting it to 3 like you’ve got it normally set and see what happens.

Also, what did you change between the 1st video you have and the 2nd? If it worked in the first one then go back to that version.

I haven’t changed the code at all, it just tends to do this after the first attempt. It floats up in the air when set to 0 hipheight when ragdolled.

  • Best fix for this is changing the weight of the objects
    • (possibly.)

I still want the object to fall, I feel changing the weight will change the way it jumps or falls.

So, code it so that the weight changes after a fraction of a second.

Just try increasing the Velocity in this line until it works:
script.Parent.PrimaryPart.Velocity = (script.Parent.PrimaryPart.CFrame.LookVector * 75) + Vector3.new(0,75,0)

It seems to be the issue is that the velocity is not being applied.

Since Velocity is deprecated you may want to use a BodyForce: BasePart | Documentation - Roblox Creator Hub