How can i make twice "while true do" in one script? bc this is not working..
01 | local cashh = Instance.new( "IntValue" ) |
02 | cashh.Parent = ack |
03 | cashh.Name = "Wheels" |
04 | cashh.Value = 0 |
05 | local cash = Instance.new( "IntValue" ) |
06 | cash.Parent = ack |
07 | cash.Name = "Tires" |
08 | cash.Value = 0 |
09 | while true do |
10 | wait( 120 ) |
11 | cash.Value = cash.Value + 1 |
12 | end |
13 | while true do |
14 | wait( 2 ) |
15 | cashh.Value = cashh.Value + 1 |
16 | end |
What you're look for is coroutine, It creates a new thread that doesn't interrupt the script. It can also use variables that the script has also, There are some others related to coroutine, like for example spawn, But I don't really know how to use. This works just fine.
01 | local cashh = Instance.new( "IntValue" ) |
02 | cashh.Parent = ack |
03 | cashh.Name = "Wheels" |
04 | cashh.Value = 0 |
05 | local cash = Instance.new( "IntValue" ) |
06 | cash.Parent = ack |
07 | cash.Name = "Tires" |
08 | cash.Value = 0 |
09 | coroutine.wrap( function () |
10 | while true do |
11 | wait( 120 ) |
12 | cash.Value = cash.Value + 1 |
13 | end |
14 | end )() |
15 | while true do |
16 | wait( 2 ) |
17 | cashh.Value = cashh.Value + 1 |
18 | end |