Can't break a gear into pieces on the floor and let the pieces remain on the floor when gear is gone

Hey y’all, I need some help in my scripting because I’m not very good at scripting and I want to solve this problem, I’ve looked everywhere for solutions but because my problem is so specific, it’s harder to find out how to solve it.

It is also hard to find a good title for this because of the problem being specific.

I want to make a game where you destroy stuff for lag.

The issue is that I can’t find out how to make it so that when the object gets destroyed, it leaves your inventory. And if I can’t do it, then when you deselect the object you are holding, the broken parts disappear, which I don’t want to happen because I am making a game intended to lag.

I have looked for many solutions, but I couldn’t get a good solution. I tried copying the destroyed object into the workspace so that when you break it and don’t hold the gear anymore, it will still remain on the floor as pieces, but I am not a good scripter so I didn’t know how to do it, and to delete the gear after the copy. Another attempt was to drop the gear (-which is the object), but when I wrote the script, it still was in my inventory. It was like semi-dropped, because I didn’t hold it in my hand anymore, but it was in my inventory and when I deselected the gear, the pieces still disappeared.

This is the script I made to break the object in pieces.
I used the F3X building tools plugin to weld the object easier. That’s why the weld is called BTWeld.

tool = script.Parent.Parent
handle = tool:WaitForChild(“Handle”)

tool.Activated:Connect(function()
print (“microwave dead”)
for count = 1, 82 do
script.Parent.Parent.Handle.BTWeld:Destroy()

end

end)

This script is made by watching tutorials and by looking at https://developer.roblox.com/ to learn new commands.

I get errors trying to load video footage of the problem, sorry.

Try moving the gear’s contents into workspace and then deleting the tool so it can’t be picked up again.

Also, you don’t need to hardcode the 82—you can find all the welds and delete them:

tool = script.Parent.Parent

tool.Activated:Connect(function()
  for _, child in pairs(tool:GetChildren()) do
    -- move the contents into workspace (this could also be a folder or something)
    child.Parent = workspace

    -- destroy all the welds
    for _, weld in pairs(child:GetDescendants()) do
      if weld.Name == "BTWeld" then
        weld:Destroy()
      end
  end

  -- destroy the Tool itself now that it’s emptied
  tool:Destroy()
end)

I’ve moved the gear contents into workspace and now I also have to change the proximity prompt script, I don’t know how because I’m not a good scripter and the script is made so that it would work if it is in the tool

My scripting skills are at a very low level, I can only make simple, easy scripts and often times I have to watch tutorials on how to do it

This is the proximity prompt script I have:

local Tool = script.Parent.Parent
local ProximityPrompt = script.Parent.ProximityPrompt

local TouchInterest = script.Parent:WaitForChild(“TouchInterest”)
TouchInterest:Destroy()

ProximityPrompt.Triggered:Connect(function(Player)
Tool.Parent = Player:WaitForChild(“Backpack”)
ProximityPrompt:Destroy()
end)

image

To clarify, I wasn’t telling you to literally move the tool into workspace manually. I was describing what the code I posted following that statement does.

Ohhh okay. I’ve now put everything back to normal.

I think your script was made so the other parts in the tool should be in the handle, so I’ve done it.
However, it works at first, but a few seconds later, it disappears. I see the handle gets deleted. I think it’s a simple fix, I have to move all of the parts which are in the handle into the workspace.

I’ve done a script to move all the parts from the handle to the workspace. But for some reason, it doesn’t work.

    for _, parts in pairs(script.Parent:GetChildren()) do
				-- moves the handle children into workspace
	    if parts.Name == "Part" then
		    parts = workspace
	    end
    end