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?
function BattleScript.NameGenerator() local number = math.random(100) local stringnumber = tostring(number) print(stringnumber) for battles in game.ServerStorage.Battles do if battles.Name == stringnumber then BattleScript.NameGenerator() else return stringnumber end end end
Thanks!
I'm not expert, but can you put the same function inside a function? you say this
function BattleScript.NameGenerator()
and inside the function you put this
if battles.Name == stringnumber then BattleScript.NameGenerator()