so I insert Players userID inside a table it looks something like this
{1 = "Roblox", 2 = "IDKTHISPLAYER"}
but since this is inserted in player added
I was wondering How I could use something similar to :WaitForChild on a table
It would look something like
Table:WaitForChild(Player.UserId)
But I know for a fact that WaitForChild don't work on a table
So in your case you'll be waiting for a table to hold a value or player to be added to the table? I would check a table for the existence of a key value, instead of value, in order to make it easier to wait for the existence of playername added to it.
I suppose one thing you could do is run a function that converts your current table structure temporarily so that the values become keys and then do a check for that key... you could then run a loop that returns true when the key is found.
function waitForTableValue(tbl,value,timeout_seconds) -- do some checks if timeout_seconds==nil or timeout_seconds==0 then timeout_seconds = 3 -- default to timeout_seconds end if value==nil then return false end local start_time = game.Workspace.DistributedGameTime -- you could also do a type check on tbl, but below should suffice... just be sure to make tbl a table! if tbl==nil or #tbl==0 then return false end local tmptable = {} for i,v in pairs(tbl) do tmptable[v] = i end while tmptable[value]==nil and game.Workspace.DistributedGameTime - start_time<timeout_seconds do wait(.1) end if tmptable[value]~=nil then return true end return false end
The ":WaitForChild()" also same as like":FindFirstChild()".
The call ":FindFirstChild()" does as it says. It finds the first child of a parent of which you name it. There must always be an argument, most likely a string. Let's see how it works:
game.Workspace.Figure:FindFirstChild("Humanoid")
If you think I explain too hard, explain not cleary, want to see more information with ":FindFirstChild" , click here.
Also, ":WaitForChild()" is find the thing that doesn't exist at testing mode,when you start the game, the thing will appear at the game. Like this :
local part = Instance.New("Part") part.Parent = game.Workspace part.Position = Vector3.new("0,0,0") game.Workspace:WaitForChild("Part").BrickColor = BrickColor.Random()
If you think I explain too hard, explain not cleary, want to see more information with ":WaitForChild()" , click here.
Hope I helped.Thanks for reading!