Hi, I'm new to scripting and are trying to make a mining game. Here is my script, whenever I try to hit the ore this error appears "8:attempt to perform arithmetic (sub) on userdata and number"
local Ore = game.Workspace.Ore.Gold.GoldOre
local Pick = game.StarterPack.Pic
local Health = game.Workspace.Ore.Gold.GoldOre.Health
Ore.Touched:Connect(function(hit)
if hit.Parent.Name == "Pic" then
Health = Health - 10
if Health == 0 then
Health = 30
Ore.Transparency = 1
Ore.CanCollide = false
wait(5)
Ore.Transparency = 0
Ore.CanCollide = true
end
end
end)
Thanks - WhoopsILied

4 comments
oh ok you decide to remove my post so you can get more reputation. all i did was add .value to it.
@iuclds no one removed your post. A note was added to your post to explain your answer. Just posting code does not help anyone. Please explain your answer.
@kingdom5 Thanks so much for the help but i have one question, how would i reset the health on the script?
on line 18 you would just set the health Health.Value = [your value] though I would look at using a local variable if possible.