Im making a dropper game where you ragdoll down and when you ragdoll, you sometimes get pushed up. Clip:
My Code:
local function ragdollChar(character, humanoid)
humanoid.AutoRotate = false
character.HumanoidRootPart.Anchored = false
humanoid.PlatformStand = false
humanoid:SetStateEnabled(Enum.HumanoidStateType.GettingUp,false)
humanoid:SetStateEnabled(Enum.HumanoidStateType.Ragdoll,true)
humanoid:ChangeState(Enum.HumanoidStateType.Ragdoll)
humanoid:SetStateEnabled(Enum.HumanoidStateType.Running,false)
humanoid.StateChanged:Connect(function(Old, new)
if new == Enum.HumanoidStateType.Freefall or new == Enum.HumanoidStateType.FallingDown or new == Enum.HumanoidStateType.Landed then
humanoid:ChangeState(Enum.HumanoidStateType.Ragdoll)
humanoid:SetStateEnabled(Enum.HumanoidStateType.Freefall, false)
humanoid:SetStateEnabled(Enum.HumanoidStateType.FallingDown, false)
humanoid:SetStateEnabled(Enum.HumanoidStateType.Landed, false)
end
end)
character:WaitForChild("Animate").Disabled = true
for i, v in pairs(character:GetDescendants()) do
if v:IsA("Motor6D") and v.Parent.Name ~= "HumanoidRootPart" then
local attach0 = Instance.new("Attachment")
attach0.CFrame = v.C0
attach0.Parent = v.Part0
local attach1 = Instance.new("Attachment")
attach1.CFrame = v.C1
attach1.Parent = v.Part1
local BallSocketConstraint = Instance.new("BallSocketConstraint")
BallSocketConstraint.Parent = v.Parent
BallSocketConstraint.Name = v.Name
BallSocketConstraint.Attachment0 = attach0
BallSocketConstraint.Attachment1 = attach1
BallSocketConstraint.LimitsEnabled = true
BallSocketConstraint.TwistLimitsEnabled = true
BallSocketConstraint.Enabled = true
v.Enabled = false
elseif v:IsA("MeshPart") or v:IsA("BasePart") or v:IsA("CharacterMesh") and v.Name ~= "HumanoidRootPart" then
v.CanCollide = false
end
humanoid.AutoRotate = false
character.HumanoidRootPart.CanCollide = false
end
end
script.Parent:WaitForChild("RagdollPart").Touched:Connect(function(Hit)
local char = Hit:FindFirstAncestorWhichIsA("Model")
if char and char:FindFirstChild("Humanoid") then
if not char:GetAttribute("Ragdolled") then
char:SetAttribute("Ragdolled", true)
char.Humanoid.WalkSpeed = 50
ragdollChar(char, char:FindFirstChild("Humanoid"))
end
end
end)