Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

Why is this player picker not working?

Asked by 9 years ago

Hi there! This player picker picks the blue team num1 and num2 but then doesn't put the rest of the players in the green team. I also think there might be another cause. Any ideas? Thanks :)

id = 186964027
list = {}
function AddPlayers()
for i,v in pairs (game.Players:GetChildren()) do
    table.insert(list,v)
if game:GetService("GamePassService"):PlayerHasPass(v,id) then
table.insert(list,v)
end
end
num1 = math.random(1,#list) --Number
num1 = list[num1] -- Value from the table
num1.TeamColor = BrickColor.Blue() 
num2 = math.random(1,#list) --Number
num2 = list[num2] -- Value from the table
print(num1)
print(num2)
if num2.Name == num1.Name then
 repeat
  num2 = math.random(1,#list)
  num2 = list[num2]
  num2.TeamColor = BrickColor.Blue()
 until
 num2.Name ~= num1.Name
for i,v in pairs (list) do
if v.Name ~= num1.Name and v.Name ~= num2.Name then
v.TeamColor = BrickColor.new("Bright green")
end
end
end
end
0
Any output? Muoshuu 580 — 9y
3
You haven't called the function fahmisack123 385 — 9y
0
I am calling it but I just haven't shown it here :( jjwood1600 215 — 9y

2 answers

Log in to vote
0
Answered by 9 years ago

You didn't call the function, a function needs to be called for it to work. For example, if someone needed to touch something, you would put this after your script:

script.Parent.Touched:connect(AddPlayers) -- in the parentheses, you put the function name

If you are going to do this, make sure the script is in a brick

Ad
Log in to vote
-1
Answered by 9 years ago

I am calling the function but I just haven't shown it here :(

0
Please use the Comments. woodengop 1134 — 9y
0
Sorry - forgot :) jjwood1600 215 — 9y

Answer this question