Bazzive
(Bazzive)
May 3, 2022, 11:26pm
#1
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.
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.
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!
Whincify
(Whincify)
May 3, 2022, 11:28pm
#2
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.
Bazzive
(Bazzive)
May 4, 2022, 12:07am
#3
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.
Bazzive
(Bazzive)
May 4, 2022, 12:15am
#5
It actually gives me Node when it prints
Bazzive
(Bazzive)
May 4, 2022, 12:32am
#6
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
TenBlocke
(Decablocks)
May 4, 2022, 12:37am
#7
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
Bazzive
(Bazzive)
May 4, 2022, 12:39am
#8
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
Bazzive
(Bazzive)
May 4, 2022, 7:42pm
#9
Got it working Thank you for the help!