generic image
Processing...
  • Games
  • Catalog
  • Develop
  • Robux
  • Search in Players
  • Search in Games
  • Search in Catalog
  • Search in Groups
  • Search in Library
  • Log In
  • Sign Up
  • Games
  • Catalog
  • Develop
  • Robux
   
ROBLOX Forum » Game Creation and Development » Scripting Helpers
Home Search
 

array help

Previous Thread :: Next Thread 
FIRECAKE is not online. 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
JoshuaKempfert is not online. JoshuaKempfert
Joined: 16 Feb 2013
Total Posts: 2407
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 is not online. 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
AgentFirefox is not online. AgentFirefox
Top 100 Poster
Joined: 20 Jun 2008
Total Posts: 22404
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 is not online. 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
Previous Thread :: Next Thread 
Page 1 of 1
 
 
ROBLOX Forum » Game Creation and Development » Scripting Helpers
   
 
   
  • About Us
  • Jobs
  • Blog
  • Parents
  • Help
  • Terms
  • Privacy

©2017 Roblox Corporation. Roblox, the Roblox logo, Robux, Bloxy, and Powering Imagination are among our registered and unregistered trademarks in the U.S. and other countries.



Progress
Starting Roblox...
Connecting to Players...
R R

Roblox is now loading. Get ready to play!

R R

You're moments away from getting into the game!

Click here for help

Check Remember my choice and click Launch Application in the dialog box above to join games faster in the future!

Gameplay sponsored by:
Loading 0% - Starting game...
Get more with Builders Club! Join Builders Club
Choose Your Avatar
I have an account
generic image