Right now I have been watching a tutorial on how to make a mining game for my own game (specifically tool scripts) since I’m fairly new to coding.
So far the tutorial has been helpful, but I want to be able to figure out if said item is in a folder, rather than having to go by name.
local function onTouch()
if otherPart.Name == 'Ore1' and canMine then
canMine = false
print("Rock")
end
end
So far I have tried replacing the .Name with .Parent, though that hasn’t worked
I also want it to be versatile so that it just needs to have the highest parent folder be Ore to activate
Oh right, another problem I didnt notice yet
and was confused by what output was outputting
Ok, new code
local function onTouch(otherPart)
if otherPart.Name == 'Ore1' and canMine then
canMine = false
print("Rock")
end
end
Basically otherPart is supposed to be the part the pickaxe collides with, so onTouch activates when the pickaxe touches an item, and otherPart is the item it touches
I hadn’t tried combining them, but I did just try and it didnt work
Also, does that work if the child is a model and the parent is a folder?
(I.e. this:
)
Cause
if otherPart.Name == 'Ore1' and canMine then
worked, but
if otherPart.Parent.Name == 'Ores' and canMine then
What exactly do you mean, like you have a part in the model (first .Parent gets the model) then you get the parent folder (second .Parent gets the folder)