local selected = {} mouse.Button1Down:Connect(function() local team = game.Workspace:WaitForChild(player.TeamColor.Name) if team then if mouse.Target:IsDescendantOf(team) then table.insert(selected,mouse.Target.Parent) print(unpack(selected)) end end end)
Basically if what is selected is member of team it inserts it into the table but when you select it again it inserts a second copy into the table. How can I see if its already in the table? thanks.
make a loop that goes through all the table values(or copy my code):
local function checkintable(table, object) -- put in your table and the object you are looking for for i = 1, #table do -- change the one to zero if your first place in the array is at 0 if table[i] == object then return true end end return false -- make a variable that calls this function and then add an "if then" statement saying if it returns false, then add it into the table. end)