The part is supposed to stay welded/attached to the HumanoidRootPart it hits instead of welding to another HumanoidRootPart if I shoot one. How do I modify my script to achieve this? Everytime I shoot it spawns a new ExplosionPart with a WeldConstraint but I want the function to only apply to the WeldConstraint of the part that spawns thus ignoring the old/previous spawned WeldConstraints of ExplosionParts.
The script: ```lua
local processedParts = {} – Table to store processed parts
coroutine.wrap(function()
local parts = game.Workspace.Terrain:GetChildren("ExplosionPart")
for _, part in ipairs(parts) do
if part:IsA("BasePart") and not processedParts[part] then
local weldConstraint = part:FindFirstChildOfClass("WeldConstraint")
weldConstraint.Part1 = hitPart.Parent:WaitForChild("HumanoidRootPart")
processedParts[part] = true -- Mark the part as processed
end
end
print("It got triggered 2")
end)()