How could I make a player Ragdoll when getting hit by a tool?

Hi, this is the script I already have located in ‘ServerScriptService’. I know this script isn’t complete, I just don’t no how to make a player Ragdoll when they get hit. Any help is appreciated!

Script:

local tool = script.Parent
local handle = tool.Handle

local animationController = Instance.new("AnimationController", handle)
local swingAnimation = Instance.new("Animation")
swingAnimation.AnimationId = "rbxassetid://"
animationController:LoadAnimation(swingAnimation)

tool.Activated:Connect(function()
	animationController:Play(swingAnimation)
end)

local function onCollision(otherPart)
	local humanoid = otherPart.Parent:FindFirstChild("Humanoid")
	if humanoid then
		humanoid.Health = 0
	end
end

tool.Touched:Connect(onCollision)

2 Likes

You can change the humanoid state type to a ragdoll state using

Humanoid:ChangeState(Enum.HumanoidStateType.Ragdoll)

I am working on the script please be patient im gonna make it less clunky and fix the issue

script:

local player = game:GetService("Players").LocalPlayer
local Character = player.Character or player.CharacterAdded:Wait()
Humanoid.Ragdoll = true

It will ragdoll once hit by the tool