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 » Scripters
Home Search
 

Re: How to loop through a module

Previous Thread :: Next Thread 
ArkhamDeluxe is not online. ArkhamDeluxe
Joined: 21 May 2016
Total Posts: 561
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
ArkhamDeluxe is not online. ArkhamDeluxe
Joined: 21 May 2016
Total Posts: 561
14 Jun 2017 05:47 AM
Just need help with the looping part, not the other things i mentioned
Report Abuse
Externalization is online. Externalization
Joined: 21 Aug 2013
Total Posts: 13230
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
ArkhamDeluxe is not online. ArkhamDeluxe
Joined: 21 May 2016
Total Posts: 561
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
ArkhamDeluxe is not online. ArkhamDeluxe
Joined: 21 May 2016
Total Posts: 561
14 Jun 2017 06:34 AM
Guys come on please ive been stuck on this for two days
Report Abuse
ArkhamDeluxe is not online. ArkhamDeluxe
Joined: 21 May 2016
Total Posts: 561
14 Jun 2017 06:53 AM
for the love of god, where is everyone
Report Abuse
GNUnotUNIX is not online. GNUnotUNIX
Joined: 05 Feb 2012
Total Posts: 15171
14 Jun 2017 07:01 AM
use the "for i,v in pairs" loop
just google how to do it


Report Abuse
AIicks is not online. 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 is online. 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 is not online. 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
Previous Thread :: Next Thread 
Page 1 of 1
 
 
ROBLOX Forum » Game Creation and Development » Scripters
   
 
   
  • 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