Sorry for asking so many questions, but why do these parts that are created destroy when a player touches them rather then when a tool touches them?
function CoalOre()
local Ore = Instance.new("Part",workspace)
Ore.Anchored = true
Ore.CFrame = CFrame.new(math.random(-50, 50), 1, math.random(-50, 50))
Ore.Shape = Enum.PartType.Ball
Ore.TopSurface = Enum.SurfaceType.Smooth
Ore.BottomSurface= Enum.SurfaceType.Smooth
Ore.Size = Vector3.new(3, 3, 3)
Ore.BrickColor = BrickColor.new("Black")
Ore.Material= Enum.Material.Pebble
Ore.Touched:connect(function(p)
if p.Parent.Name == "Coal Pickaxe" or "Handle" then
Ore:Destroy()
end
end)
end
while wait(math.random(2,5)) do
CoalOre()
end
EDIT:
It works fine for the other one
function CopperOres()
local CopperOre = Instance.new("Part",workspace)
CopperOre.Anchored = true
CopperOre.CFrame = CFrame.new(math.random(-50, -30), 1, math.random(-50, -3))
CopperOre.Shape = Enum.PartType.Ball
CopperOre.TopSurface = Enum.SurfaceType.Smooth
CopperOre.BottomSurface= Enum.SurfaceType.Smooth
CopperOre.Size = Vector3.new(3, 3, 3)
CopperOre.BrickColor = BrickColor.new("Copper")
CopperOre.Material= Enum.Material.Pebble
CopperOre.Touched:connect(function(p)
if p.Parent.Parent.Name == "Copper Pickaxe" then
CopperOre:Destroy()
local humanoid = (p:FindFirstAncestorOfClass("Model") or p.Parent):FindFirstChild("Humanoid")
local player = game.Players:GetPlayerFromCharacter(humanoid.Parent)
local leaderstats = player:FindFirstChild("leaderstats")
local Coins = leaderstats:FindFirstChild("Gold")
if Coins then Coins.Value = Coins.Value + 10
end
end
end)
end
while wait(math.random(12,15)) do
CopperOres()
end