How would I make part, that if you touch your head comes off

Hello! I am currently trying to make a part, that if you touch your head comes off, and I’m going to put that part on a axe. I’m not the best at scripting though, I’m still trying to learn. I think I have an idea, But I don’t know. Here is what I have:

Part.Touched:Connect(function(Object)
if Object.Parent:FindFirstChild(“Humanoid”) then
(I don’t know how to find the head yet.)

end)
end

That’s as far as I got. If you could help me, that would be great.

Once you get Object.Parent (The character), simply add this line of code:

Object.Parent:FindFirstChild("Head"):Destroy()

After the if statement, you have the character, which contains a head. Destroying that head will maek the head pop off and kill you. However, it might not give you the animation you desire.

1 Like

Part.Touched:Connect(function(Object)
if Object.Parent:FindFirstChild(“Head”):Destroy()

end)
end

1 Like

Almost! Keep the code you have, just put it in the if statement.

Part.Touched:Connect(function(Object)
    if Object.Parent:FindFirstChild(“Humanoid”) then
          local character = Object.Parent
          local head = character:FindFirstChild("Head")
          head:Destroy()
    end)
end

Yes, this should be a server script.

If you destroy the head, the character will die.

I’m assuming that’s OP’s goal.

1 Like

Yes, I want the player to die. I’m trying to make a theatre but I’m gonna have a weapon stash in it.

1 Like

Got it, the code given should work then!

1 Like

You need to declare the value of the part. So I would do

local Part = game.Workspace.Part

The value after game.Workspace should be the name of the part

I thought about that, I really did, but oh well.

Wait, how do I make only the head come off? Would I weld them together?

When a player dies, their parts fall like that, I would look into a ragdoll model script or research how to make one yourself.

Do you know any good ones, if so can you tell me?

This should work, it’s from my game, Noir.

local character = script.Parent
character:WaitForChild("Humanoid").BreakJointsOnDeath = false

local died
died = character.Humanoid.Died:Connect(function()
	local d = character:GetDescendants()
	for i=1,#d do
		local desc = d[i]
		if desc:IsA("Motor6D") then
			local socket = Instance.new("BallSocketConstraint")
			local part0 = desc.Part0
			local joint_name = desc.Name
			local attachment0 = desc.Parent:FindFirstChild(joint_name.."Attachment") or desc.Parent:FindFirstChild(joint_name.."RigAttachment")
			local attachment1 = part0:FindFirstChild(joint_name.."Attachment") or part0:FindFirstChild(joint_name.."RigAttachment")
			if attachment0 and attachment1 then
				socket.Attachment0, socket.Attachment1 = attachment0, attachment1
				socket.Parent = desc.Parent
				desc:Destroy()
			end	
		elseif desc:IsA("Script") or desc:IsA("LocalScript") then
			desc:Destroy()
		end
	end
end)

Make it a serverscript inside startercharacterscripts.

Where is the server script. I can’t find it, I thought I heard of it before image

The one called “Script” is a server script.

It just runs on the server

Oh, heh, should have just said Script, I’m not that smart.

Well, now you know! If that works, be sure to mark the solution so readers know it’s been solved!

image