Need help with resource mining system

Im trying to create a mining system like in games such as Rust. Managed to make a tool but im getting stuck on applying damage to the resource.

  1. I can get the tool to play animation, but when i try to find my “Node” in workspace and apply damage to its health nothing happens.

  2. I tried searching for any documentation but its hard to find. I also havent scripted for that long so still trying to understand most of it.

All help is incredibly appreciated!

Do all of your prints print? If so, also print dmg to ensure it is not nil. Scratch that second part I didn’t see dmg is defined at the top.

No only the animation prints. It doesnt detect the Rock tool coliding with the Node

how about printing hit.Parent right before the if collect:HasTag(hit.Parent, "Node") then line.

It actually gives me Node when it prints

So do i need to actually give a Tag to the Node? Found this post CollectionService in a nutshell

I cant test it right now but would i need this in a script inside the Rock?

local CollectionService = game:GetService("CollectionService") 

CollectionService:AddTag(script.Parent, "Node")
1 Like

Yes, you need to add the tag to your rock nodes or CollectionService:HasTag(hit.Parent, “Node”) will return false every single time. And, i do NOT recommend you put a script in every rock just to add a tag to it, instead i suggest you get all your rocks in a for loop, and add the tag to it, or, as soon as your rocks are created, add the tag to them.

1 Like

Ok then i will try this in the morning! The plan is to generate all these resources so that shouldnt be an issue.

1 Like

Got it working :slight_smile: Thank you for the help!