I'm making a mining game, and was wondering how to make the minerals change location in the mines. The minerals are currently humanoids, that can be killed by the pick axes. What could I do, to make the minerals(humanoids) spawn in different locations within the mine? I was thinking about making a groups of the minerals invisible/cannot collide, and another group, and when a mineral dies, it makes the other group visible/can collide. Please help me figure this out, I've been trying to make this work for a looooong time!
I don't know if the mineral is welded or anything. If it's not, you can make a table of possible positions the mineral can spawn at and use Humanoid.Died to respawn the mineral to different locations.
Here's an example:
01 | local Positions = { Vector 3. new( 23 , 23 , 23 ), Vector 3. new(- 21 , 23 ,- 43 ) } -- Possible locations |
02 | local Mineral = script.Parent |
03 | local BackUp = Mineral:clone() -- The mineral that will spawn next |
04 |
05 | local function SwitchPosition() -- Create then move the new mineral |
06 | BackUp.Parent = workspace |
07 | BackUp:MakeJoints() |
08 | BackUp:MoveTo(Positions [ math.random( 1 ,#Positions) ] ) -- Move the mineral to one of locations |
09 | Mineral:Destroy() -- Remove the old dead mineral |
10 | end |
11 |
12 | Mineral:WaitForChild( 'Humanoid' ).Died:connect(SwitchPosition) --Fires when the mineral dies |
Hope I help or at least gave you an idea.