|
| 14 Jun 2017 05:46 AM |
got a module that goes
module = { Armors = { ["BronzeArmor"] = { ["LevelRequired"] = "1" }, ["IronArmor"] = { ["LevelRequired"] = "4" }, } }
How can i loop through this module when a player levels up (done this code already) so i can check if the new level matches the level required to add it to their list of unlocked characters?
|
|
|
| Report Abuse |
|
|
|
| 14 Jun 2017 05:47 AM |
Just need help with the looping part, not the other things i mentioned
|
|
|
| Report Abuse |
|
|
|
| 14 Jun 2017 05:54 AM |
game.Players.LocalPlayer.level.Changed:connect(function() --run code you wanna loop once level is changed
end
|
|
|
| Report Abuse |
|
|
|
| 14 Jun 2017 06:18 AM |
come on man that wasnt the question, How do you loop through the module table is the question
for i,v in ipairs?
for i = 1,#Armors or what? |
|
|
| Report Abuse |
|
|
|
| 14 Jun 2017 06:34 AM |
| Guys come on please ive been stuck on this for two days |
|
|
| Report Abuse |
|
|
|
| 14 Jun 2017 06:53 AM |
| for the love of god, where is everyone |
|
|
| Report Abuse |
|
|
|
| 14 Jun 2017 07:01 AM |
use the "for i,v in pairs" loop just google how to do it
|
|
|
| Report Abuse |
|
|
AIicks
|
  |
| Joined: 10 Apr 2012 |
| Total Posts: 788 |
|
|
| 14 Jun 2017 07:10 AM |
Haven't tested but I'd assume it's just
local requiredModule = require(module)
for k, v in pairs(requiredModule) do print(k, v) end
|
|
|
| Report Abuse |
|
|
TaaRt
|
  |
| Joined: 26 Apr 2009 |
| Total Posts: 5039 |
|
|
| 14 Jun 2017 09:14 AM |
for _,v in pairs(module) do for topic,b in pairs(v) do for key,value in pairs(b) do print(topic,key,value) -- Bronze Armour , level required , 1 end end end |
|
|
| Report Abuse |
|
|
chimmihc
|
  |
| Joined: 01 Sep 2014 |
| Total Posts: 17143 |
|
|
| 14 Jun 2017 09:35 AM |
There is nothing special about module scripts. Stop thinking they are some other datatype.
They are literally just scripts that return something. You can think of them like cached global function, where requiring calls them. |
|
|
| Report Abuse |
|
|