How to have a function that makes sure folder names are different?
In a battle system I'm working on, each battle has a folder with the amount of players fighting and the players fighting, and the amount of enemies and the enemy object values. In a name generator function, the funciton generates a name for the folder to be called. To make sure each of these folder names are different to seperate them, it checks if the number it randomly chose is the same as to any of the folder names. However, the way I'm doing it doesn't work. What am I doing wrong?
01 | function BattleScript.NameGenerator() |
02 | local number = math.random( 100 ) |
03 | local stringnumber = tostring (number) |
06 | for battles in game.ServerStorage.Battles do |
07 | if battles.Name = = stringnumber then |
08 | BattleScript.NameGenerator() |
Thanks!