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

Error on 2nd Line of script to get team captains- Please help?

Asked by 7 years ago
Edited by OldPalHappy 7 years ago

Here's the script:

local pes = game.Teams.PES:GetPlayers
local fifa = Teams.FIFA:GetPlayers


local myArray = {fifa, pes}

#myArray 
math.random(x) 
myArray[x] 

myArray[math.random(#myArray)]

end)

I'm basically trying to get team captains for a soccer game. The 2nd 'local' has an error for some reason and I can't seem to figure out why.

2 answers

Log in to vote
0
Answered by 7 years ago
Edited 7 years ago

wookey12's answer is incorrect. I'll show you the method to get a random player from each team here... this script chooses a random captain for each team

local PESmembers = game.Teams:WaitForChild("PES"):GetPlayers()
local FIFAmembers = game.Teams:WaitForChild("FIFA"):GetPlayers()

local PEScaptain = PESmembers[math.random(#PESmembers)]
local FIFAcaptain = FIFAmembers[math.random(#FIFAmembers)]
0
Does this allow me to give the same random captain a gui/hopperbin? comotose 3 — 7y
0
Yes, the PEScaptian and FIFAcaptian are player instances, so you can just clone the GUI into PEScaptian.PlayerGui (or FIFAcaptian) and hopperbins into PEScaptian.Backpack joritochip 705 — 7y
Ad
Log in to vote
-1
Answered by
wookey12 174
7 years ago

in the second variable (or local as you called it) you need to add "game" right before "Teams"

local pes = game.Teams.PES:GetPlayers
local fifa = game.Teams.FIFA:GetPlayers
local myArray = {fifa, pes}
0
That didn't work, I appreciate your time, although! comotose 3 — 7y

Answer this question