I have this script in SeverScriptService
local p = table()
for i, v in pairs
do
game.Players:GetPlayers()
table.insert(#p, v.Name)
end
print(#p)
The error in the output says "ServerScriptService.Script:1: attempt to call a table value"
I have this script in SeverScriptService
local p = table()
for i, v in pairs
do
game.Players:GetPlayers()
table.insert(#p, v.Name)
end
print(#p)
The error in the output says "ServerScriptService.Script:1: attempt to call a table value"
To get a random player you index a random number in the players service:
local Rando = game.Players:GetChildren()[math.random(1,#game.Players:GetChildren())]
returns the player not the character.
also remember,
local table = {} -- create a table
and
for i, v in pairs(list) do
-- code
end
if this helps then upvote and click answer, k thx
First of all, you're creating the table wrong. the way you create a table is,
local table = {}
Secondly, GetPlayers() already returns a table, so i don't see a use of doing that.
Thanks
This discussion is preserved as it was. New answers, comments, and votes are closed.
2 comments
Using GetPlayers() is better since it only returns the player objects.
but ofc you wont create an instance and parent it to players xd