Detach a body part and keep it intact, no inherint animations and stays on the ground. Is this the best way?

Hi all. I wanted to make player’s parts fall off and fall to the ground and also not keep animating when the character is moving. Had a look around for something quick but couldn’t find much so I wrote the below code. It works perfectly, and one advantage is that I can just re enable the Motors to re attach the part back to the player if need be in the game. But just wondering if there is a more efficient way to do it. Cause all this is just for one arm :upside_down_face:

Also the only draw back with it is that if the player is jumping at the time, the part falls right through the ground. So I disabled jump just before the script runs to stop that from happening.

local Players = game:GetService("Players")
Players.PlayerAdded:Connect(function(player)
	local character = player.Character or player.CharacterAdded:Wait()
	task.wait(5)
	-- PARTS
	local rightUpperArm = character.RightUpperArm
	local rightLowerArm = character.RightLowerArm
	local rightHand = character.RightHand

	-- Create Welds
	local LowerToUpperWeld = Instance.new("WeldConstraint") -- Glue Lower and Upper Arms together
	LowerToUpperWeld.Part0 = rightUpperArm
	LowerToUpperWeld.Part1 = rightLowerArm
	LowerToUpperWeld.Parent = rightLowerArm

	local lowerToHandWeld = Instance.new("WeldConstraint") -- Glue Lower and Hand together
	lowerToHandWeld.Part0 = rightLowerArm
	lowerToHandWeld.Part1 = rightHand
	lowerToHandWeld.Parent = rightHand

	-- Turn on collisions so doesn't fall through floor
	rightUpperArm.CanCollide = true
	rightLowerArm.CanCollide = true
	rightHand.CanCollide = true

	-- Disable Motors
	rightHand.RightWrist.Enabled = false
	rightLowerArm.RightElbow.Enabled = false
	rightUpperArm.RightShoulder.Enabled = false
end)
1 Like

What if you clone the body part, make the original transparent & disable collision (so you can get it back), then drop the cloned part to the ground?

If I clone it, it won’t retain what the player is wearing.
But I can attach the limb back to the player just by re-enabling the Motor (As long as the limb didn’t fall into the ether).
Iv’e since re-written as a Function. Now I can call the function with the names of body parts to drop

local function DropBodyParts(...)
	local args = {...}
	local character = currentPlayer.Character
	-- PARTS
	if #args == 0 then print("No arguments, exiting function") return end
	if #args == 1 then -- A single bodypart to drop with no welds needed
		print("Dropping: "..args[1])
		local bodyPart = character:FindFirstChild(args[1])
		if bodyPart then -- If it exists
			bodyPart.CanCollide = true
			bodyPart:FindFirstChildWhichIsA("Motor").Enabled = false
		end
	elseif #args == 2 then -- Two bodyparts to drop one weld needed
		print("Dropping: "..args[1].." and "..args[2])
		local bodyPart1 = character:FindFirstChild(args[1])
		if bodyPart1 then
			local bodyPart2 = character:FindFirstChild(args[2])
			if bodyPart2 then
				print("Found both Parts")
				-- Weld them
				local weld = Instance.new("WeldConstraint")
				weld.Part0 = bodyPart1
				weld.Part1 = bodyPart2
				weld.Parent = bodyPart2
				-- Allow collisions
				bodyPart1.CanCollide = true
				bodyPart2.CanCollide = true
				-- Detach from Player
				bodyPart1:FindFirstChildWhichIsA("Motor").Enabled = false
				bodyPart2:FindFirstChildWhichIsA("Motor").Enabled = false
			end
		end
	elseif #args == 3 then -- Three bodyparts to drop, Two welds needed
	end
end

task.wait(4)
-- Syntax - send through Weld Root first and children after
DropBodyParts("RightUpperArm","RightLowerArm","RightHand")
1 Like

Check this out

3 Likes

Ahh, yes. That link just made me realize I can just clone the entire Character, make an array of the body parts and use the parts at will. Way simpler. Nice…

Thanks mate :grin:

2 Likes

Happy to help! Glad that solved it for you :slight_smile:

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.