Hi, so I was making a game in which the gravity would randomize every 15 seconds. For this I divided it into 3 gravity ranges and used the 'math.random' function. After this I also wanted the gravity pattern randomized also. Like for example if the 3 ranges are 25-75, 80-150 and 200-275 and a random gravity gets selected from these ranges(for eg 60 from range 1 and so on)I also wanted the pattern to be randomized so that I don't have control of what range of gravity is gonna be selected. Any one of the three ranges will be selected at random every 15 seconds, it doesn't have a pattern. Here came the problem. Since I am not a really good scripter I tried randomizing the patterns also with 'math.random'. The script has no errors but it doesn't change the gravity for some reason. When I tried checking the gravity it just comes as the default and doesn't change. Pasting in the code block I used so you guys can see if I did any mistakes (I most likely did as I am new to scripting, also I didn't loop in the function as I was just testing).
local gravity = game.Workspace.Gravity local RandomNumber = math.random(25,75) local RandomNumber2 = math.random(76,125) local RandomNumber3 = math.random(225,275) print("Gravity loop has started") game.Workspace.Gravity = 196.2 wait(15) function RandomPattern () local RandomGrav = math.random(1,3) if RandomGrav == 1 then gravity = RandomNumber elseif RandomGrav == 2 then gravity = RandomNumber2 elseif RandomGrav == 3 then gravity = RandomNumber3 else -- do nothing end end RandomPattern()