• There is NO official Otland's Discord server and NO official Otland's server list. The Otland's Staff does not manage any Discord server or server list. Moderators or administrator of any Discord server or server lists have NO connection to the Otland's Staff. Do not get scammed!

Lua Problem in table

anderkrox

New Member
Joined
May 14, 2020
Messages
21
Reaction score
1
Why don't work?
Lua:
dificuldade = 1



local niveis = {
        [1] = {chance = 1000000},
        [2] = {chance = 250000},
        [3] = {chance = 62500},
    }
    for k,v in pairs(niveis) do
        if dificuldade == k then
            local random = math.random(1, 100000)
            -- if random <= (niveis[k].chance / self:getStorageValue(storage)) then self:addHabilCustom(nome, storage) end
            print("Key: ".. k ..", chance: ".. niveis[k].chance ..".")
        else
            print("addHabilidadeCustomizada: Precisa ter um nivel de dificuldade, escolha '1', '2', ou '3'.")
        end
        break
    end
When the "dificuldade = 1" return "Key: 1, chance: 1000000.", but if I set "dificuldade" to another number, for example: "dificuldade = 2", the script return "
addHabilidadeCustomizada: Precisa ter um nivel de dificuldade, escolha '1', '2', ou '3'."

I need this msg: "Key: 2, chance: 250000."
 
you are not allowing it to loop through as you have put the break after the if statement, move the break under print("key~
 
Back
Top