num = 5 mult = 5 while true do wait(0.25) math.random(1,10) if math.random() ~= 10 then print(num) elseif math.random() == 10 then print(num * mult) end end
i'm trying to make an rng system that prints the number if the number that was picked was not equal to 10 if the number is equal to 10 it will multiply the number by 5 but for some reason, it doesn't seem to work as expected it should have a 10% chance of printing the number 25 but it keeps printing 5 how do i fix this?
math.random()
returns a value of 0 to 1 so asking if math.random() ~= 10 then
will always be true but elseif math.random() == 10 then
will always fail.
To fix your code, I would change it to the following:
local num = 5 local mult = 5 while true do wait(0.25) local Chance = math.random(1,10) if Chance ~= 10 then print(num) elseif Chance == 10 then print(num * mult) end end