Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

How could I make this script shorter?

Could anyone help me by making this script shorter? I want the rotation number to never stop going up, so it is an endless loop of the rotation. (The script's parent is a ImageLabel, Not a brick.)

if script.Disabled == false then

    script.Parent.Rotation = 1
    wait(0.01)
    script.Parent.Rotation = 2
    wait(0.01)
    script.Parent.Rotation = 3
    wait(0.01)
    script.Parent.Rotation = 4
    wait(0.01)
    script.Parent.Rotation = 5
    wait(0.01)
    script.Parent.Rotation = 6
    wait(0.01)
    script.Parent.Rotation = 7
    wait(0.01)
    script.Parent.Rotation = 8
    wait(0.01)
    script.Parent.Rotation = 9
    wait(0.01)
    script.Parent.Rotation = 10
    wait(0.01)
    script.Parent.Rotation = 11
    wait(0.01)
    script.Parent.Rotation = 12
    wait(0.01)
    script.Parent.Rotation = 13
    wait(0.01)
    script.Parent.Rotation = 14
    wait(0.01)
    script.Parent.Rotation = 15
    wait(0.01)
    script.Parent.Rotation = 16
    wait(0.01)
    script.Parent.Rotation = 17
    wait(0.01)
    script.Parent.Rotation = 18
    wait(0.01)
    script.Parent.Rotation = 19
    wait(0.01)
    script.Parent.Rotation = 20
    wait(0.01)
    script.Parent.Rotation = 21
    wait(0.01)
    script.Parent.Rotation = 22
    wait(0.01)
    script.Parent.Rotation = 23
    wait(0.01)
    script.Parent.Rotation = 24
    wait(0.01)
    script.Parent.Rotation = 25
    wait(0.01)
    script.Parent.Rotation = 26
    wait(0.01)
    script.Parent.Rotation = 27
    wait(0.01)
    script.Parent.Rotation = 28
    wait(0.01)
    script.Parent.Rotation = 29
    wait(0.01)
    script.Parent.Rotation = 30
    wait(0.01)
    script.Parent.Rotation = 31
    wait(0.01)
    script.Parent.Rotation = 32
    wait(0.01)
    script.Parent.Rotation = 33
    wait(0.01)
    script.Parent.Rotation = 34
    wait(0.01)
    script.Parent.Rotation = 35
    wait(0.01)
    script.Parent.Rotation = 36
    wait(0.01)
    script.Parent.Rotation = 37
    wait(0.01)
    script.Parent.Rotation = 38
    wait(0.01)
    script.Parent.Rotation = 39
    wait(0.01)
    script.Parent.Rotation = 40
    wait(0.01)
    script.Parent.Rotation = 41
    wait(0.01)
    script.Parent.Rotation = 42
    wait(0.01)
    script.Parent.Rotation = 43
    wait(0.01)
    script.Parent.Rotation = 44
    wait(0.01)
    script.Parent.Rotation = 45
    wait(0.01)
    script.Parent.Rotation = 46
    wait(0.01)
    script.Parent.Rotation = 47
    wait(0.01)
    script.Parent.Rotation = 48
    wait(0.01)
    script.Parent.Rotation = 49
    wait(0.01)
    script.Parent.Rotation = 50
    wait(0.01)
    script.Parent.Rotation = 51
    wait(0.01)
      end 

2 answers

✓ Accepted answer

Use a for loop:

for i = 1, 51 do
	script.Parent.Rotation = i
	wait(0.01)
end

Use a loop.

Here's a simple for loop that will do this:

	for rotation = 1, 51 do
		script.Parent.Rotation = rotation;
		wait(0.01);
	end

Note that your check if script.Disabled == true then is probably pointless or at best confusing, since if the script (was) disabled the nothing will happen.

3 comments

0

I put "if script.Disabled == true" because i was too lazy to find on the wiki what I needed to get it to start when the server started :)

0

You don't need anything! Scripts start as soon as the server starts

0

This was when I quit scripting and got back on track a month later ;)

This discussion is preserved as it was. New answers, comments, and votes are closed.