|
| 06 Apr 2015 07:25 PM |
function mapSelect() local mapStore = store:findFirstChild("maps") local chosenMap = mapStore[math.random(1,#mapStore:getChildren())] local map for i,v in next, mapStore:getChildren() do print(i..": "..v) if i == chosenMap then map = v print(v) end end return map end
still returning a number... ?
i told it to return map! (v) which would be a model |
|
|
| Report Abuse |
|
|
cntkillme
|
  |
| Joined: 07 Apr 2008 |
| Total Posts: 44956 |
|
|
| 06 Apr 2015 07:31 PM |
| why don't you just return chosenMap, why have the loop at all... And also i will never be chosenMap because shoenMap is going to be an object |
|
|
| Report Abuse |
|
|
|
| 06 Apr 2015 07:33 PM |
because it's gonna return the actual map
and if i replace
if i == chosenMap then with if i == 1 then it works fine? wtf? |
|
|
| Report Abuse |
|
|
cntkillme
|
  |
| Joined: 07 Apr 2008 |
| Total Posts: 44956 |
|
|
| 06 Apr 2015 07:34 PM |
Are you stupid, or are you just trolling? If the latter, get out.
"it's gonna return the actual map" "i told it to return map! (v) which would be a model"
|
|
|
| Report Abuse |
|
|
|
| 06 Apr 2015 07:35 PM |
| I'm not trolling... I'm serious. |
|
|
| Report Abuse |
|
|
|
| 06 Apr 2015 07:35 PM |
| If I replace the var chosenMap with an actual int it does return the model... but I need it to work for chosenMap instead of an int because it needs to be random. |
|
|
| Report Abuse |
|
|
|
| 06 Apr 2015 07:38 PM |
wow... I realize why I'm stupid now.
I was setting it to mapStore[random int] and trying to compare an int to a userdata
wow
i feel stupid |
|
|
| Report Abuse |
|
|
cntkillme
|
  |
| Joined: 07 Apr 2008 |
| Total Posts: 44956 |
|
|
| 06 Apr 2015 07:40 PM |
| I still don't understand why you don't return the chosen map... |
|
|
| Report Abuse |
|
|
|
| 06 Apr 2015 07:42 PM |
because mapSelect() returns the actual userdata of the model.
later in the script i do
local map = mapSelect()
which is way easier than doing
local map = game.ServerStorage.maps[math.random(1,#game.ServerStorage.maps:getChildren())] |
|
|
| Report Abuse |
|
|
cntkillme
|
  |
| Joined: 07 Apr 2008 |
| Total Posts: 44956 |
|
|
| 06 Apr 2015 07:43 PM |
I don't know if you understand what I'm trying to say or not... Whatever, if words won't help this should:
local mapSelect = function() local children = store.maps:GetChildren(); return children[math.random(#children)]; end;
local map = mapSelect(); |
|
|
| Report Abuse |
|
|
|
| 06 Apr 2015 07:44 PM |
wait a second
i suddenly feel even stupider..
i didn't get what you were saying ugh i h8 my life |
|
|
| Report Abuse |
|
|