Part won't stop destroying dummies

Basically, my part, once activated, won’t stop destroing the dummies.

Hello! I have a part that once you activate it with a proximity prompt, it destroys any dummies with the Child “torsoWeld”. For some reason, when I activate the part, it infinitly destroys the dummies. I only want it to destroy the existing ones and not infinitly destroy dummies.

script.Parent.Triggered:Connect(function(plr)

		game.Workspace.Claw.ClawHelper.Touched:Connect(function(hit)
			if hit.Name == "torsoWeld" then
				local remover = hit.Parent
				remover:Destroy()										
		end
	end)
end)

how do I make it so that it doesn’t destroy dummies infinitly?

as you can see, it just keeps on destroying them without stopping.

other problems you see in the video, i will fix later.

1 Like

Touched is a connection so this means you can disconnect it, store it in a variable then once the dummy is destroyed then disconnect the connection

script.Parent.Triggered:Connect(function(plr)
    local con
	con = game.Workspace.Claw.ClawHelper.Touched:Connect(function(hit)
		if hit.Name == "torsoWeld" then
			local remover = hit.Parent
			remover:Destroy()
            if con then con:Disconnect() end									
		end
	 end)
end)
2 Likes

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