How do I make y if it is a certain number do what I say and not do what I say if it doesn't choose that number like for example if math.random 1 got chosen then it would do v.Value = v.Value * 1.1 * math.random(1, 1.5) but if it's any other number like 5 it wouldn't do that. Or is this not possible?
local balance = {-1, 1} local v = game.Lighting:WaitForChild("ONE") local sway = math.random(1, 100) * .01 local y = math.random(1, 6) local x = math.random(1, 8) while wait() do wait(15) v.Value = v.Value + sway for y = 1,2 do v.Value = v.Value * 1.1 * math.random(1, 1.5) for x = 2,3 do v.Value = v.Value - v.Value + 2.50 end end end
What you are looking for is a If statement.
If statements run only when the statements is true or false depending on how you use not
.
To put it as an example:
local i = 1 if i == 1 then print('YO!') else print('i is not 1') end
In this example, if i is 1 (which it is) it will print YO, while if i is not 1 (anything other then 1) it will print something else.
From you script it seems like you are trying to make a loop (make it continues) here is your code refined:
local balance = {-1, 1} local v = game.Lighting:WaitForChild("ONE") local sway = math.random(1, 100) * .01 local y = math.random(1, 6) local x = math.random(1, 8) while true do wait(15) v.Value = v.Value + sway if y == 1 then -- do what you want elseif y == 2 then -- do what you want elseif y == 3 then -- do what you want elseif y == 4 or y == 5 then -- you can also do this -- do what you want end end
A few things, you have to add what you want to do and I want to make sure that you know x, y and sway will always stay the same because it only runs once.
If you want it to keep changing, place the variables inside the while true do loop so it runs again.
Hopefully this helped you.
Best of luck!