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)
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)
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)
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.