I have this here bit of code. its for a weapon, a pickaxe to be exact. I want it to work so that when you mine it, the rock, which is an entity, gets removed. but it doesnt seem to wanna work.
local Owner = self.Owner local Trace = util.GetPlayerTrace(self.Owner) local Target = util.TraceLine(Trace).Entity if IsValid(Target) then if Owner:GetPos():Distance(Target:GetPos()) < 80 then if Target:GetNWString("Ore") != "" and Target:GetNWString("Ore") != "wood" then Owner:ChatPrint("Gathering...") Owner:Freeze(true) timer.Simple(5, function() Target:Remove() local RandAmount = math.floor(math.Rand(1,10)) Owner:AddItem("ore_".. Target:GetNWString("Ore"), RandAmount) Owner:ChatPrint("You have gathered ".. RandAmount.. " ".. Target:GetNWString("Ore")) Owner:Freeze(false) end) else Owner:ChatPrint("You can't gather that!") end end end