Hello all! I have run into quite the dilemma. I have created clones of an object and each object created has either a value of “Red” or “Blue” depending on which team they are on:
,
for i = 1, scorchSpawnLimit do
table.insert(redTeamMinionsLane1, redScorchMinion:Clone())
table.insert(blueTeamMinionsLane1, blueScorchMinion:Clone())
-- Set the primary part to head
redTeamMinionsLane1[i].PrimaryPart = redTeamMinionsLane1[i].Head
blueTeamMinionsLane1[i].PrimaryPart = blueTeamMinionsLane1[i].Head
redTeamMinionsLane1[i].Name = "Minion"
blueTeamMinionsLane1[i].Name = "Minion"
-- Move the primary part to the spawn
redTeamMinionsLane1[i]:SetPrimaryPartCFrame(redMinionSpawn1.CFrame * CFrame.new(5 * i, 0, 0))
blueTeamMinionsLane1[i]:SetPrimaryPartCFrame(blueMinionSpawn1.CFrame * CFrame.new(5 * i, 0, 0))
-- Assign to lane
redTeamMinionsLane1[i].Head.Lane.Value = "CheckPointsLane1"
blueTeamMinionsLane1[i].Head.Lane.Value = "CheckPointsLane1"
-- Assign to team
redTeamMinionsLane1[i].Head.TeamValue.Value = "Red"
blueTeamMinionsLane1[i].Head.TeamValue.Value = "Blue"
minionScript:Clone().Parent = redTeamMinionsLane1[i]
minionScript:Clone().Parent = blueTeamMinionsLane1[i]
-- Move the model to workspace
redTeamMinionsLane1[i].Parent = game.Workspace
blueTeamMinionsLane1[i].Parent = game.Workspace
_G.minionCount = _G.minionCount + 1
wait()
end
,
There is more code, but I believe this will suffice. Each object also has a health bar. Whenever the size of the health bar reaches (0, 0, 1, 0), I want the game to destroy the clone and remove it from the list according to its team.
I know the table.remove() function takes two parameters: the table and the index. How do I find the index of the object if they are all the same? Thanks!