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:
local Positions = {Vector3.new(23,23,23), Vector3.new(-21,23,-43)} -- Possible locations local Mineral = script.Parent local BackUp = Mineral:clone() -- The mineral that will spawn next local function SwitchPosition() -- Create then move the new mineral BackUp.Parent = workspace BackUp:MakeJoints() BackUp:MoveTo(Positions[math.random(1,#Positions)]) -- Move the mineral to one of locations Mineral:Destroy() -- Remove the old dead mineral end Mineral:WaitForChild('Humanoid').Died:connect(SwitchPosition) --Fires when the mineral dies
Hope I help or at least gave you an idea.