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?
01 | local balance = { - 1 , 1 } |
02 | local v = game.Lighting:WaitForChild( "ONE" ) |
03 | local sway = math.random( 1 , 100 ) * . 01 |
04 | local y = math.random( 1 , 6 ) |
05 | local x = math.random( 1 , 8 ) |
06 | while wait() do |
07 |
08 | wait( 15 ) |
09 | v.Value = v.Value + sway |
10 | for y = 1 , 2 do v.Value = v.Value * 1.1 * math.random( 1 , 1.5 ) |
11 | for x = 2 , 3 do v.Value = v.Value - v.Value + 2.50 |
12 | end |
13 | end |
14 | 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:
1 | local i = 1 |
2 |
3 | if i = = 1 then |
4 | print ( 'YO!' ) |
5 | else |
6 | print ( 'i is not 1' ) |
7 | 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:
01 | local balance = { - 1 , 1 } |
02 | local v = game.Lighting:WaitForChild( "ONE" ) |
03 | local sway = math.random( 1 , 100 ) * . 01 |
04 | local y = math.random( 1 , 6 ) |
05 | local x = math.random( 1 , 8 ) |
06 |
07 | while true do |
08 | wait( 15 ) |
09 | v.Value = v.Value + sway |
10 | if y = = 1 then |
11 | -- do what you want |
12 | elseif y = = 2 then |
13 | -- do what you want |
14 | elseif y = = 3 then |
15 | -- do what you want |
16 | elseif y = = 4 or y = = 5 then -- you can also do this |
17 | -- do what you want |
18 | end |
19 | 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!