FIRECAKE
|
  |
| Joined: 28 Feb 2009 |
| Total Posts: 25167 |
|
|
| 18 Jun 2014 04:06 PM |
i have an array of lots of variables that i want to check for with an "if then" but i don't want to spend time doing
if player.Name == (Array[1]) or player.Name == (Array[2]) etc etc then blah blah blah
how do i condense it so that it searches the entire array at once |
|
|
| Report Abuse |
|
|
|
| 18 Jun 2014 04:08 PM |
local function SearchArray(Array, Player) for i,v in pairs(Array) do if Player.Name == v then return true end end return false end
|
|
|
| Report Abuse |
|
|
FIRECAKE
|
  |
| Joined: 28 Feb 2009 |
| Total Posts: 25167 |
|
|
| 18 Jun 2014 04:09 PM |
| ok hold that thought ill write some code and see what happens |
|
|
| Report Abuse |
|
|
|
| 18 Jun 2014 04:10 PM |
"ok hold that thought ill write some code and see what happens"
You've earned not only a like from me, but also +1 internet point. And a heart.
<3 |
|
|
| Report Abuse |
|
|
FIRECAKE
|
  |
| Joined: 28 Feb 2009 |
| Total Posts: 25167 |
|
|
| 18 Jun 2014 04:28 PM |
ok here's what I got right now
Washington = {} Ottowa = {} Hartford = {} Tampa = {} Texas = {} Columbus = {}
WJersey = Workspace.Washington:FindFirstChild("Shirt") OJersey = Workspace.Ottowa:FindFirstChild("Shirt") HJersey = Workspace.Hartford:FindFirstChild("Shirt") TaJersey = Workspace.Tampa:FindFirstChild("Shirt") TeJersey = Workspace.Texas:FindFirstChild("Shirt") CJersey = Workspace.Columbus:FindFirstChild("Shirt")
game.Players.PlayerAdded:connect(function(Player) for i,v in pairs(Washington) do if Player.Name == v then local s = Player:FindFirstChild("Shirt") if s then s:remove() end local sn = WJersey:Clone() sn.Parent = Player end end end)
all of the variables are defined correctly and I'm aware that the arrays currently have no values input
would this work? |
|
|
| Report Abuse |
|
|