#attempt to get length of instance value when trying to get a random player

1 messages · Page 1 of 1 (latest)

lusty jolt
#

idk what to do
the code i sent is what casued the error btw

rough atlas
#

may I see the error

copper sparrow
#

:GetPlayers()

lusty jolt
topaz warrenBOT
#

studio** You are now Level 10! **studio

lusty jolt
#

here the error

#

also heres the whole thing

#

i was trying to change the team of that specific player

lusty jolt
copper sparrow
#

use the service and call :GetPlayers()

rough atlas
#

try to separate them

#

then do the getplayers

#

``lua

#

oh bruh

#

lua

#

wait I forgot how to do it holdon

lusty jolt
#

shuld i do like

#

a filterarray or smoething

rough atlas
#

holdon

#

what are you trying to

#

do?

lusty jolt
#

basically

#

im trying to pick 1 random player and then put them on a specific team

rough atlas
#
local Players = game:GetService("Players")

for _, player in Players:GetPlayers() do
    print(player.Name)
end
lusty jolt
rough atlas
#

yea but change the value

lusty jolt
#

which value

#

the underscore?

frail mulch
#

local table = Players:GetPlayers()

local killer = math.random(1, #table)

lusty jolt
#

ok ima try that

copper sparrow
#

crazy fix

rough atlas
#

you have the team

#

?

sacred wedge
#

local a = Players:GetPlayers()
local b = math.random(1, #a)
a[b]

#

gg

sacred wedge
#

use table fields or attributes or sum sh

#

!!

lusty jolt
#

it doesen;t get an actual player

frail mulch
lusty jolt
#

and then i added an extra line to change the teamcolor

#

and now it chooses a random player each time

#

thamks everyone!!111

#

closin cuz solved