Delete instance after parenting script to other instance

Hey lads, I am making a roomba that you can pick up.

When attempting to pick up/drop the roomba, I have no way to clean up the workspace/player’s backpack.

Attempted to make a wait then destroy script, attempted to destroy via script.Parent. Also had an idea of removing the stuff using remote events. Didn’t work too.

The script I made to drop & pick up the roomba is quite simple.

script.Parent.ClickDetector.RightMouseClick:Connect(function(plr)
	local tool = Instance.new("Tool")
	for i,v in pairs(script.Parent:GetChildren()) do
		v.Parent = tool
		if v:IsA("Part") then
			v.CanCollide = false
		end
	end
	tool.GripForward = Vector3.new(0,-0,-1)
	tool.GripPos = Vector3.new(0,-1,-1)
	tool.GripRight = Vector3.new(1,-0,0)
	tool.GripUp = Vector3.new(0,1,-0)
	script.Parent.ClickDetector.MaxActivationDistance = 0
	script.Parent.Torso.ProximityPrompt.Enabled = false
	tool.Parent = plr.Character
	tool.Unequipped:Connect(freedom)
end)

function freedom()
	local model = Instance.new("Model")
	for i,x in pairs(script.Parent:GetChildren()) do
		x.Parent = model
		if x:IsA("Part") then
			x.CanCollide = false
		end
	end
	script.Parent.ClickDetector.MaxActivationDistance = 32
	if script.Parent.ok.Value == true then
		script.Parent.Torso.ProximityPrompt.Enabled = true
	end
	model.Parent = workspace
end

Would appreciate your help!

You probably should define your freedom() function before the click detector event.

I could figure it out myself lad. The main problem here is that I cant remove the model/tool after i moved all the instances to the tool

So why not just destroy the Tool instance itself then?

Good idea, but I should somehow remove the model too

Since the model is inside tool, it should get deleted as well?