Why is random not being random? Okay so this script is in a loop. It does a random outcome, but it just spams the same outcome it chose. For example lets say at the beginning of the game it chose "Outcome 2," now the script loops, so it goes back to the beginning, and it has to chose "Outcome 1-6," but it picks "Outcome 2 again." This repeats on the same server. However if it was a different server it would choose AT THE BEGINNING of the game a random outcome. Lets say this NEW server picks "Outcome 1," when the script loops, it spams that "Outcome 1." Why is this happening? Thanks!
local randomDanger = math.random(1, 2) local randomSpeed = math.random(1, 3) while true do wait(1) if randomDanger == 1 then if randomSpeed == 1 then --Outcome 1 wait(4) elseif randomSpeed == 2 then --Outcome 2 wait(4) elseif randomSpeed == 3 then --Outcome 3 wait(4) end elseif randomDanger == 2 then if randomSpeed == 1 then --Outcome 4 wait(4) elseif randomSpeed == 2 then --Outcome 5 wait(4) elseif randomSpeed == 3 then --Outcome 6 wait(4) end end end
Hello.
The issue is,you are not re-assigning the value to have a random value inside the while loop.
Here is a fixed version:
while true do local randomDanger = math.random(1, 2) local randomSpeed = math.random(1, 3) wait(1) if randomDanger == 1 then if randomSpeed == 1 then --Outcome 1 wait(4) elseif randomSpeed == 2 then --Outcome 2 wait(4) elseif randomSpeed == 3 then --Outcome 3 wait(4) end elseif randomDanger == 2 then if randomSpeed == 1 then --Outcome 4 wait(4) elseif randomSpeed == 2 then --Outcome 5 wait(4) elseif randomSpeed == 3 then --Outcome 6 wait(4) end end end