IDKBlox
|
  |
| Joined: 05 Apr 2013 |
| Total Posts: 1304 |
|
|
| 13 May 2016 05:08 PM |
okay I want to do a round script...
is there a way I can use this
GameModes={Original,New Gamemode,and so on}
loop here to go trough the game modes?"
then
if ChosenGamemode == "Original then do this elseif ChosenGamemode=="New Gamemode" then do this end
Is there a Way I can do this? if so can someone explain how please :)
Thank you very much :) |
|
|
| Report Abuse |
|
|
IDKBlox
|
  |
| Joined: 05 Apr 2013 |
| Total Posts: 1304 |
|
|
| 13 May 2016 05:09 PM |
| or is there a way I can make a remote function using this or something lol.. Thanks |
|
|
| Report Abuse |
|
|
IDKBlox
|
  |
| Joined: 05 Apr 2013 |
| Total Posts: 1304 |
|
|
| 13 May 2016 05:22 PM |
Wait I think I figured it out... Can someone please explain how I can loop through this
local Maps = { "Test", "Test2", }
and choose a random one
Thanks :) |
|
|
| Report Abuse |
|
|
sparker22
|
  |
| Joined: 11 Mar 2010 |
| Total Posts: 846 |
|
|
| 13 May 2016 05:24 PM |
Elements in a table are indexed from 1 to the number of elements. They are numerical unless specified otherwise. The most common method to loop through a table is a generic loop.
for i,v in pairs(Maps) do -- i is the index, v is the value end
To select a random map just generate a random number between 1 and the number of elements in a table. (#Maps would return that) and access the table with the number being the indexed.
local SelectedMap = Maps[math.random(1,#Maps)] |
|
|
| Report Abuse |
|
|
IDKBlox
|
  |
| Joined: 05 Apr 2013 |
| Total Posts: 1304 |
|
|
| 13 May 2016 05:33 PM |
Thanks! Which one of those would you prefer to use while me using a table using
Maps={} |
|
|
| Report Abuse |
|
|
sparker22
|
  |
| Joined: 11 Mar 2010 |
| Total Posts: 846 |
|
|
| 13 May 2016 05:35 PM |
Getting a random map, use the math.random() approach.
You should only iterate through a table when you need to compare every value against something or manipulate every value. |
|
|
| Report Abuse |
|
|
IDKBlox
|
  |
| Joined: 05 Apr 2013 |
| Total Posts: 1304 |
|
|
| 13 May 2016 05:38 PM |
| Will take that into consideration... Thank you very much for the help! |
|
|
| Report Abuse |
|
|
IDKBlox
|
  |
| Joined: 05 Apr 2013 |
| Total Posts: 1304 |
|
|
| 13 May 2016 05:52 PM |
| another quick question... Is there a way to make event:FireServer(Map) work in a script in the workspace? |
|
|
| Report Abuse |
|
|
|
| 13 May 2016 06:07 PM |
Depends how it is setup. Only players can fire the server, I'm pretty sure.
r+://393244197r+://393244224r+://393244262 |
|
|
| Report Abuse |
|
|