1 | workspace.CoreC.Temp.Value + = 1 |
Hey, you could use a while loop or a repeat loop for that :D
While Loop:
1 | local CoreC = game.Workspace.CoreC.Temp -- Defines your part or whatever |
2 |
3 | while true do -- Will run forever |
4 |
5 | CoreC.Value = CoreC.Value + 1 -- Set to how much the value is supposed to be |
6 | wait( 1 ) -- You want to have some cooldown or the game will crash |
7 | end |
Repeat Loop:
1 | repeat |
2 |
3 | CoreC.Value = CoreC.Value + 1 -- Set to how much the value is supposed to be |
4 | wait( 1 ) -- You want to have some cooldown or the game will crash |
5 |
6 | until MyRepeater = = false -- Basicaly runs forever untill MyRepeater is set to false |
https://developer.roblox.com/en-us/articles/Loops
There are two ways: One is a while true loop. This one is only needed if you are adding in a wait in between each cycle. An example is if I want a countdown to go down every second. EXAMPLE:
1 | local countdownTime = 60 |
2 | local countdown = countdownTime |
3 | local inc = 1 |
4 | while wait(inc) do --Every second this will run |
5 | countdown - = inc --Setting the countdown variable to itself, but 1 less. |
6 | end |
The second is a Run.Stepped function. This is only ran if you want it to run constantly every second. Using a wait() at the end won't work.
If you are on a server script, the only way to use it is like this:
1 | local run = game:GetService( "RunService" ) |
2 | run.Stepped:Connect( function () |
3 | --do whatever here. |
4 | end ) |
But, if you are on a client (local) script, it can be used in two ways.
1 | local run = game:GetService( "RunService" ) |
2 | run.Stepped:Connect( function () |
3 | --do whatever here. |
4 | end ) |
5 | run.RenderStepped:Connect( function () |
6 | --do whatever here |
7 | end ) |
The difference between Stepped and RenderStepped is that RenderStepped is better if you are, for example, making arms that follow your cursor client sided. If you use .Stepped, it'll lag out and glitch, but if you use .RenderStepped, it will look nice and smooth.