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

['For' loop issue] Can someone just explain to me why this is giving an error? [closed]

Asked by
Necrorave 560 Moderation Voter
9 years ago

I am at a loss here. It looks fine to me.

I should know how to fix simple issues like this, but I am lost.

I am getting an error for something that should be somewhat simple. Can someone please point out the possible issue. I have fooled around with this for a bit now and cannot figure out the problem.

for x = 100, x > 85, -5 do
        game.StarterGui.Rain.Dark.BackgroundTransparency = x / 100
end

The error:

22:22:31.718 - ServerScriptService.Rain:6: attempt to compare number with nil

Thanks

0
Could you post the full script? Also maybe put a wait in the for loop. Octillerysnacker 115 — 9y
0
The rest of the script doesn't matter (I isolated the incident and got the same result). Also, a wait() will not make a difference. Necrorave 560 — 9y
0
Showing the rest of this script will help us to further understand the problem. Also, are you sure that you can do 'x > 85'? Because, I've never seen a 'for' loop do that before. :P TheeDeathCaster 2368 — 9y

Locked by adark and BlueTaslem

This question has been locked to preserve its current state and prevent spam and unwanted comments and answers.

Why was this question closed?

1 answer

Log in to vote
4
Answered by
Merely 2122 Moderation Voter Community Moderator
9 years ago

The second part of the for loop is the "end number", it's not supposed to be an expression like x > 85.

Try this instead:

for x = 100, 85, -5 do

More info on for loops on the wiki: http://wiki.roblox.com/index.php?title=For_loop#For

1
Ah, okay. I am resorting back to C# again. Thanks. Necrorave 560 — 9y
Ad