What I would like to know is, how do I create a loop in a script? By that I mean like having a brick flash colors or something, over and over and over. I hope you can help me...
P.S. ROBLOX News is
awesome!
-cblack9999
Dear cblack9999,
for loops
are very simple. They are used to repeat something a certain amount of times. For example, to make a brick flash colors using a for loop
, you can make it flash only a certain amount of times. For example:
for i=1,4 do
script.Parent.BrickColor = BrickColor.new("Really red")
wait(0.2)
script.Parent.BrickColor = BrickColor.new("Really blue")
end
That will run four times. However, there is a way to make it completely random! Just by using
BrickColor.random()
! Here is an example:
for i=1,4 do
script.Parent.BrickColor = BrickColor.random()
wait(0.2)
end
Here is a breakdown.
for
That basically says 'do the following'....The next part:
i=1
That says 'start at one'.
The final part:
,5 do
This says 'Until i equals 5 continue'.
All in all:
for i=1,5 do
print("Loop has run "..i.." times!")
end
No comments:
Post a Comment
Write your comment here... OR Flingi will eat you