I am wondering how I manipulate the name in the table that's created in this script.
for i,v in pairs(game.Players:GetPlayers()) do print(v) end
As you can see here, it'd print out all the players, though lets say I am trying to find Player1 and if he is in the game, then I want to remove him. How would I go about doing this? All I can figure out how to do with 'i,v in pairs() do' is print tables.
You don't have to use a for loop. Just use the FindFirstChild
method. This method searches for a child, by name, and returns that child if it exists. Otherwise it returns nil. This makes it useful when coupled with an if statement to check if something exists.
if game.Players:FindFirstChild("Player1") then game.Players.Player1:Kick() end
I do not know how to use i,v in pairs, but this is my idea:
local a = game.Players:GetChildren() for i = 1,# do print(a[i].Name) a[i]:Destroy() end