Need help adding Defense

I’ve recently been working on a mining system for a project I’m working on, and I had an idea to add Sturdiness/Defense to rocks so stronger rocks will be harder to mine for lower-level pickaxes.
However, I’ve been hitting roadblocks on finding a way how to make this idea come to life.
I’ve added an int value called “Damage” in the pickaxe and a value in the rock called “Defense”

I’m trying to make it where the Defense will reduce the amount of damage the pickaxe does.

image

image

any help would be very appreciated!

in the local script of the wooden pickaxe

script.Parent.Handle.Touched:Connect(function(hit)

if hit.Name == "DeepRock" then
   hit.Health -= Script.Parent.Damage - hit.Defence
end

end)

Alternatively it would be a lot simpler to just make harder rocks have more hp

Alos note, that when you change something in a local script, it only changes for the client. So for example if you destroy the rock in the local script, for all the other players rock wont be destroyed

The local script calls an event that damages the rock in the server so I’m not really worried bout that

ok so I found a solution

local Def = Defense.Value/100
local Dmg = Damage.Value - Damage.Value * Def
1 Like