How can i make twice "while true do" in one script? bc this is not working..
local cashh = Instance.new("IntValue") cashh.Parent = ack cashh.Name = "Wheels" cashh.Value = 0 local cash = Instance.new("IntValue") cash.Parent = ack cash.Name = "Tires" cash.Value = 0 while true do wait(120) cash.Value = cash.Value + 1 end while true do wait(2) cashh.Value = cashh.Value + 1 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.
local cashh = Instance.new("IntValue") cashh.Parent = ack cashh.Name = "Wheels" cashh.Value = 0 local cash = Instance.new("IntValue") cash.Parent = ack cash.Name = "Tires" cash.Value = 0 coroutine.wrap(function() while true do wait(120) cash.Value = cash.Value + 1 end end)() while true do wait(2) cashh.Value = cashh.Value + 1 end