generic image
Processing...
  • Games
  • Catalog
  • Develop
  • Robux
  • Search in Players
  • Search in Games
  • Search in Catalog
  • Search in Groups
  • Search in Library
  • Log In
  • Sign Up
  • Games
  • Catalog
  • Develop
  • Robux
   
ROBLOX Forum » Game Creation and Development » Scripters
Home Search
 

Re: Remove something from a table w/o knowing its spot?

Previous Thread :: Next Thread 
Klink45 is not online. Klink45
Joined: 06 Jun 2011
Total Posts: 26054
15 May 2016 06:22 PM
I want to remove the selected player from the table, but I don't know the spot it will be. I know how to use table.remove() but how can I remove something if I don't know where in the table it is?

local adornees = players:GetChildren() --Players is defined don't worry :)
local memer = adornees[math.random(1, #adornees)]
--I want to remove memer from the table somehow?
table.remove(adornees)

u sicko!
Report Abuse
AggressiveCatch is not online. AggressiveCatch
Joined: 17 Jul 2011
Total Posts: 5840
15 May 2016 06:23 PM
local memer = math.random(1, #adornees)
table.remove(adornees, memer)
Report Abuse
0Dan is not online. 0Dan
Joined: 22 Oct 2009
Total Posts: 2552
15 May 2016 06:43 PM
Loop through the table?
for i,v in pairs(adornees) do
print(v.Name) --player name
end


Report Abuse
Klink45 is not online. Klink45
Joined: 06 Jun 2011
Total Posts: 26054
15 May 2016 06:53 PM
@Agressive
bad argument #2 to 'remove' (number expected, got Object)
@0Dan no.

u sicko!
Report Abuse
TimeTicks is not online. TimeTicks
Joined: 27 Apr 2011
Total Posts: 27115
15 May 2016 06:55 PM
for i,v in next, adornees do
if memer == v then
table.remove(adornees,i)
end
end


Report Abuse
0Dan is not online. 0Dan
Joined: 22 Oct 2009
Total Posts: 2552
15 May 2016 07:04 PM
local adornees = game:GetService("Players"):GetChildren()
local memer = math.random(1,#adornees)
table.remove(adornees, memer)


Report Abuse
0Dan is not online. 0Dan
Joined: 22 Oct 2009
Total Posts: 2552
15 May 2016 07:07 PM
^ that worked perfectly fine for me, I checked the table before and after
so if it doesn't work then it's probably something you're doing


Report Abuse
Klink45 is not online. Klink45
Joined: 06 Jun 2011
Total Posts: 26054
15 May 2016 07:10 PM
Thanks.

u sicko!
Report Abuse
12103net is not online. 12103net
Joined: 08 Jul 2013
Total Posts: 350
15 May 2016 07:32 PM
local function findTableObject(table, value)
for i,v in pairs(table) do
if v==value then
return i
end
end
end

returns the index of a value in table
Report Abuse
Previous Thread :: Next Thread 
Page 1 of 1
 
 
ROBLOX Forum » Game Creation and Development » Scripters
   
 
   
  • About Us
  • Jobs
  • Blog
  • Parents
  • Help
  • Terms
  • Privacy

©2017 Roblox Corporation. Roblox, the Roblox logo, Robux, Bloxy, and Powering Imagination are among our registered and unregistered trademarks in the U.S. and other countries.



Progress
Starting Roblox...
Connecting to Players...
R R

Roblox is now loading. Get ready to play!

R R

You're moments away from getting into the game!

Click here for help

Check Remember my choice and click Launch Application in the dialog box above to join games faster in the future!

Gameplay sponsored by:
Loading 0% - Starting game...
Get more with Builders Club! Join Builders Club
Choose Your Avatar
I have an account
generic image