Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
1

I have more than 500 ores in my game. How to handle them?

Asked by 6 years ago

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?

0
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 Async_io 908 — 6y
1
i like your username vanilla_wizard 336 — 6y

1 answer

Log in to vote
0
Answered by
Scaii_0 145
6 years ago

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.

0
My suggestion is the second as the first would be very inefficient. Scaii_0 145 — 6y
0
@Scaii_0 the variable limit is 200 not sure if you know that DeceptiveCaster 3761 — 6y
0
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. Scaii_0 145 — 6y
Ad

Answer this question