I have two ores: Gold Ore and Iron ore. The parts are exactly the same except for the color and the name.
Inside the parts: Script #2 Damage Needed(Value) Damage(Value)
In the picax:
local Damage = 0 ------------------------------ local MiningSound = script.Parent.MiningSound local MinedSound = script.Parent.MinedSound ------------------------------ function reset() DamageNeeded = 0 Damage = 0 end --------------------------------------- script.Parent.Handle.Touched:connect(function(basePart) if (basePart.Name == "IronOre") then local player = game.Players:FindFirstChild(script.Parent.Parent.Name) local ironore = game.ReplicatedStorage.UnrefinedIronOre:Clone() if (player) then DamageNeeded = basePart.DamageNeeded.Value Damage = Damage+1 MiningSound:Play() if Damage >= DamageNeeded then ironore.Parent = player.Backpack MinedSound:Play() basePart.Name = "CannotMineIronOre" basePart.Transparency = 1 basePart.CanCollide = false wait(10) reset() basePart.Name = "IronOre" basePart.Transparency = 0 basePart.CanCollide = true end ----------------------------------------------------------- if (basePart.Name == "GoldOre") then local player = game.Players:FindFirstChild(script.Parent.Parent.Name) local goldore = game.ReplicatedStorage.UnrefinedGoldOre:Clone() if (player) then DamageNeeded = basePart.DamageNeeded.Value Damage = Damage+1 MiningSound:Play() if Damage >= DamageNeeded then goldore.Parent = player.Backpack MinedSound:Play() basePart.Name = "CannotMineGoldOre" basePart.Transparency = 1 basePart.CanCollide = false wait(10) reset() basePart.Name = "GoldOre" basePart.Transparency = 0 basePart.CanCollide = true end end end return (nil); end end end)
In the Gold Ore: hits = script.Parent.Damage.Value hitsneeded = script.Parent.DamageNeeded.Value function onTouch(hit) if hit.Parent.Name == "RustyPicax" then hits = hits+1 script.Parent.Mine:Play() wait(0.5) end if hits > hitsneeded then script.Parent.CanCollide = false script.Parent.Transparency = 1 print "GoldOreMined" end end script.Parent.Touched:connect(onTouch)
When the picaxe touches a part, if it is Iron ore or Gold ore it is supposed to increase the hits by 1 until it is >= to the hits needed.
Mining Iron Ore Works fine, Gold doesn't do a thing. Why does Iron work and not gold?
I don’t think you can define the value of an intvalue in a variable, try taking value out and then adding it to whenever you call the variable. Hope that works for you.