More optimal solution for welding parts to a player character corpse please

hello, i have a LOCAL script where i weld ice blocks to the character when they die but the welds just dont work at all, the prints suggest its active and working but the parts just fall through the floor

ive narrowed it down the the BreakJointsOnDeath but i want this on

ive tried handling on the server but it both didnt work and is undesirable

never mind i just broke the joints manually but if there is a better more optimal solution please let me know

server code

local rs = game:GetService("ReplicatedStorage")
local event = rs.Remotes:FindFirstChild("DeathVisuals")
local otherevent = rs.Remotes:FindFirstChild("DamageVisuals")

--if types isnt a table then itll explode lol
-- nvm added failsafe im so good at coding

return function(hum:Humanoid, damage:number, types:any)
	
	--not important
	
	if hum.Health <= 0 then --important stuff here
		for _,v in hum.Parent:GetDescendants() do
			if v:IsA("Motor6D") then
				v:Destroy()
			end
		end
		event:FireAllClients(hum, hum.Parent, types)
	end
end

–client code

for _,v in hum.Parent:GetChildren() do
			if v.Name == "HumanoidRootPart" then continue end
			if v:IsA("BasePart") then
				
				local ice = Instance.new("Part", character)
				ice.Name = "ice"
				ice.BrickColor = BrickColor.new("Pastel Blue")
				ice.Transparency = 0.2
				ice.Reflectance = 0.25
				ice.Size = Vector3.new(v.Size.X + 0.1, v.Size.Y + 0.1, v.Size.Z + 0.1)

				--ice.Anchored = true
				--ice.CanCollide = false
				
				task.wait()

				local weld = Instance.new("WeldConstraint")
				weld.Parent = ice
				weld.Part1 = ice
				weld.Part0 = v
				weld.Enabled = true

				task.wait()
				ice.Position = v.Position
				ice.Orientation = v.Orientation

				--print(weld.Parent,weld.Part1, weld.Part0, weld.Enabled, weld.Active)

				local d = 1
				local f = .005 --Set this to a lower number for a better slide effect.
				local e = 1
				local fw = 100 --Set this to a higher number for a better slide effect.
				local ew = 1
				local Properties = PhysicalProperties.new(d, f, e, fw, ew)
				ice.CustomPhysicalProperties = Properties
			end
1 Like

Hey there. You could perhaps use recursion for your problem. I was playing around, and I eventually made this code that works. Essentially, I have a function that takes in the character and a part, then it creates a weld between the part and the character’s hand and listens for the “Parent” property changed signal for the weld, and call itself if the parent is nil.

TL;DR
It’s a recursive function that recreates the weld when it’s destroyed

local player = game.Players.LocalPlayer
local character = player.Character or player.CharacterAdded:Wait()
local humanoid = character:WaitForChild("Humanoid")

local function weldPart(character: Model, part: Part)
	local arm = character:WaitForChild("LeftHand")
	if not arm then return end
	
	local weld = Instance.new("Weld")
	weld.Part0 = arm
	weld.Part1 = part
	weld.Parent = part
	part.Parent = character
	
	weld:GetPropertyChangedSignal("Parent"):Once(function()
		if weld.Parent then return end
		weldPart(character, part)
	end)
end

local part = Instance.new("Part")
part.CanCollide = false
weldPart(character, part)

player.CharacterAdded:Connect(function(char)
	character = char
	humanoid = char:WaitForChild("Humanoid")
	
	part = Instance.new("Part")
	part.CanCollide = false
	weldPart(character, part)
end)

You can use this same logic for your code.