Basically what the title says. I want to use a table and get the children from that table. What should I do?
GetChildren gives you a table to use. So in any way that you would use GetChildren, do the same thing but without GetChildren.
for index, value in pairs(yourTable) do
Alright, thank you very much! 3 O Chars
Also, since I don’t want to make 2 dev posts in the span of 10 minutes, do you know how I could get a random player from the plr list? I am super tired so I srsly can’t remember a thing.
local Players = game:GetService("Player")
local playerList = Players:GetPlayers()
local randomPlayer = playerList[math.random(#playerList)]
print(randomPlayer)
Nvm it was that players was “player” not “players”. Thank you!
Alr so I am using this to sit the random plr but it doesn’t seat them, what’s wrong?
local SeatsContainer = {game.Workspace.Vehicles.CarModel1.FL, game.Workspace.Vehicles.CarModel2.FL}
local Players = game:GetService("Players")
local playerList = Players:GetPlayers()
local randomPlayer = playerList[math.random(#playerList)]
for i,Seat in SeatsContainer do
if Seat.Occupant then continue end
Seat:Sit(randomPlayer.Character.Humanoid)
end```
Seat:Sit
will only work on the client for the local player.
for i,Seat in SeatsContainer do
Has generic iteration been shipped to Roblox? You may still need to use ipairs
.
ohhh, ok. Thanks! `````3 O chars```
local Players = game:GetService("Players")
local playerList = Players:GetPlayers()
local randomPlayer = playerList[math.random(#playerList)]
Is this code ran instantly? An experience initially loads with zero players.