Is this your full script? I can’t seem to replicate the error. Are there any specific steps you take before it happens?
I should also note your check p.Parent.Name == "Coal Pickaxe" or "Handle" doesn’t do what you want it to do. This will evaluate to true for every item that touches your part. What you want is p.Parent.Name == 'Coal Pickaxe' or p.Parent.Name == 'Handle'
Few things you should do is first do what Autterfly said. Also, when modifying properties, or just creating instances in general, you should use
local part= Instance.new("Part")
part.Parent = workspace
Also for the touched event, you could just do
if p:IsDescendantOf(pickaxe) then
I don’t know why this is not working but try changing the “Ore” variable to "orePart’ it might be getting it confused with the function somehow.
Does your pickaxe tool have a script inside that also destroys the coal ore? Calling “Destroy” twice in two different scripts will throw this error because the 2nd Destroy will have nothing to remove from the game. If that’s the case, you can try to remove either script.
Second connection sees that the part is already destroyed
These are my solutions:
Disconnect the function with :Disconnect()
local Connection
Connection = Ore.Touched:connect(function(p)
if p.Parent.Name == "Coal Pickaxe" or "Handle" then
Ore:Destroy()
Connection:Disconnect()
end
end)
Or you can sue Debris:
local DS = game:GetService("Debris")
Ore.Touched:connect(function(p)
if p.Parent.Name == "Coal Pickaxe" or "Handle" then
DS:AddItem(Ore, 0)
end
end)
This is unnecessary. Instance::Destroy implicitly disconnects all connections, so this is not the issue. What likely happened was OP did something like
function Ore()
end
And the code ended up seeing it as a function and not an instance.