Each ore has health and will get destroyed if it's health gets to 0. How do I handle this? Do I give each ore it's own script or would that be too inefficient?
I have more than 500 ores in my game. How to handle them?
1 answer
Well if you want to find all the ores in one place, you could use
:GetDescentdants()
If you group all the ores into a single model or folder it would go like:
game.Workspace.OresInAModelInThis:GetDescendants(Ores)
So, you have a list of everything in "OresInThisModel" and everything inside the all children of that.
For more info on :GetDescendants() look on the RobloxWiki
From there you can do two things.
One
If you go ahead with a script in each ore, you can use the GetDescandants and do this:
game.Workspace.OresInAModelInThis:GetDescendants(Ores)
if Ores:IsA("Script") == true then
Ores.Disabled = false
--Rest of script here
Two
You could control everything from the descendant.
game.Workspace.OresInAModelInThis:GetDescendants(Ores)
if Ores:IsA("Part") == true then --Or whatever instance the ores is
--Rest of script here because I don't know your workspace
--Include a local for the Health value, find it using If value IsA('IntValue')
--If it goes down to zero 'if health.value == 0 then'
--Then local health.Parent:Destroy()
For more info on IsA you can check that on the wiki too.
3 comments
My suggestion is the second as the first would be very inefficient.
@Scaii_0 the variable limit is 200 not sure if you know that
Sorry I forgot that he was talking about 200. Maybe just put them into separate models based on their location or something and have a script handling each one that is the same.
This discussion is preserved as it was. New answers, comments, and votes are closed.

2 comments
You'll probably have to resort to each ore having it's own script. It's already going to be inefficient if you have 500 ores
i like your username