Hey so whenever a player gets hit by my tomato tool by their lower torso, they ragdoll, after they ragdoll, it seems like they cannot get up. I was wondering if there was a way to fix that.
local sizeX = math.random(2, 4) -- Random size between 2 and 4
local sizeY = math.random(2, 4) -- Random size between 2 and 4
local part = Instance.new("Part")
part.Size = Vector3.new(sizeX, sizeY, 0.1) -- Make the part thin
part.Anchored = true
part.CanCollide = false
part.Transparency = 1
part.CFrame = CFrame.new(hitPosition, hitPosition + hitNormal)
part.Parent = workspace
part.Touched:Connect(function(hit)
local h = hit.Parent:FindFirstChild("Humanoid")
local root = hit.Parent:FindFirstChild("HumanoidRootPart")
if h and root and not h:GetAttribute("IsRagdolled") then
h:SetAttribute("IsRagdolled", true)
h:ChangeState(Enum.HumanoidStateType.Physics)
h.PlatformStand = true
h.BreakJointsOnDeath = false
local char = h.Parent
local ragdollConstraints = {}
-- Apply constraints
for _, joint in pairs(char:GetDescendants()) do
if joint:IsA("Motor6D") then
local socket = Instance.new("BallSocketConstraint")
local a1 = Instance.new("Attachment")
local a2 = Instance.new("Attachment")
a1.CFrame = joint.C0
a2.CFrame = joint.C1
a1.Parent = joint.Part0
a2.Parent = joint.Part1
socket.Attachment0 = a1
socket.Attachment1 = a2
socket.LimitsEnabled = true
socket.TwistLimitsEnabled = true
socket.Parent = joint.Parent
joint.Enabled = false
table.insert(ragdollConstraints, socket)
table.insert(ragdollConstraints, a1)
table.insert(ragdollConstraints, a2)
end
end
-- Enable collisions for body
for _, part in pairs(char:GetDescendants()) do
if part:IsA("BasePart") then
part.CanCollide = true
end
end
-- Nudge velocity
local lowerTorso = char:FindFirstChild("LowerTorso")
if lowerTorso then
root.Velocity = lowerTorso.CFrame.LookVector * 2
end
-- Recover after 4 seconds
task.delay(4, function()
if h and h.Parent then
-- Move character up slightly to avoid getting stuck
if root then
root.CFrame = root.CFrame + Vector3.new(0, 3, 0)
end
-- Disable collisions on feet temporarily to help unstick
local function safeCollision(partName)
local part = char:FindFirstChild(partName)
if part then part.CanCollide = false end
end
safeCollision("LeftFoot")
safeCollision("RightFoot")
safeCollision("LeftLowerLeg")
safeCollision("RightLowerLeg")
-- Clean up constraints
for _, obj in ipairs(ragdollConstraints) do
if obj and obj.Parent then
obj:Destroy()
end
end
-- Re-enable joints
for _, joint in pairs(char:GetDescendants()) do
if joint:IsA("Motor6D") then
joint.Enabled = true
end
end
h.PlatformStand = false
h:SetAttribute("IsRagdolled", false)
h:ChangeState(Enum.HumanoidStateType.GettingUp)
-- Re-enable collisions after a moment
task.delay(0.5, function()
safeCollision("LeftFoot")
safeCollision("RightFoot")
safeCollision("LeftLowerLeg")
safeCollision("RightLowerLeg")
end)
end
end)
end
end)