Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

How make a "for" loop that repeats its task every 0.1 seconds?

Asked by 4 years ago

How do I make a "for" loop that repeats its task every 0.1 seconds?

0
Wait a Moment. I will create a Script for you Ferrarimami 120 — 4y

2 answers

Log in to vote
0
Answered by 4 years ago

Hey. It's pretty easy. You want a For Loop, that loops around a table every 0,1 Seconds, right? You could just do this:

1while wait(0.1) do -- executes every 0.1 seconds
2    for i, v in pairs(game:GetChildren()) do -- add your for loop here
3        -- your code here that should execute every 0.1 seconds for i and v.
4    end -- for loop end
5end -- while end

Example: Teleportation:

1while wait(0.1) do
2    for i, v in pairs(game.Players:GetChildren()) do -- example for loop, loops through players
3        v.Character.PrimaryPart.Position = Vector3.new(0, 64, 0) -- example code line
4    end
5end
0
Thank you! ViktorRamstrom 15 — 4y
0
No problem! Ferrarimami 120 — 4y
Ad
Log in to vote
0
Answered by 4 years ago
1while wait(0.1) do
2    -- your code here
3end

Easy and simple loop. You can learn more about loops here: https://developer.roblox.com/en-us/articles/Loops

0
you don't have to post something twice btw. Ferrarimami 120 — 4y

Answer this question