Debris AddItem Not Removing the Part

I am literally have a line inside of my script in Roblox Studio that uses game.Debris method to not yield the code but my part do not destroying in 5 seconds even though I put hit and 5 seconds

Code:

script.Parent.Touched:Connect(function(hit)
	if hit.Anchored == false and not hit.Name == "Saw" then
			hit:BreakJoints()
		hit.Size = hit.Size - Vector3.new(.5,.5,.5)
		game:GetService("Debris"):AddItem(hit,5)
	end

end)

VIDEO:

No error was given

Try declaring the service before, so that you don’t keep getting the service:

local Debris = game:GetService("Debris")
script.Parent.Touched:Connect(function(hit)
	if hit.Anchored == false and not hit.Name == "Saw" then
		hit:BreakJoints()
		hit.Size = hit.Size - Vector3.new(.5,.5,.5)
		Debris:AddItem(hit, 5)
	end
end)

Ok I tried but it didn’t work It’s still the same

Try printing after each line, like:

local Debris = game:GetService("Debris")
script.Parent.Touched:Connect(function(hit)
	if hit.Anchored == false and not hit.Name == "Saw" then
		print("1")
		hit:BreakJoints()
		print("2")
		hit.Size = hit.Size - Vector3.new(.5,.5,.5)
		print("3")
		Debris:AddItem(hit, 5)
		print("4")
	end
end)

Also, is this script for every saw in the box?

That script is for then neon white transparent part:

ANd what happening is that it’s not even working, like, the truck touched it but doesnt shred

The part has script and touchcan on

Can you take an image of the explorer, like just the part with the saw and the script.

image

emphasized text
emphasized text

Change not hit.Name == "Saw" to hit.Name ~= "Saw", apparently the second method works, but not the first.
OR
you can make not hit.Name == "Saw" to not (hit.Name == "Saw"), however the above method is better.

3 Likes

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