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

Why can I add, but not subtract?

Asked by
Maxomega3 106
10 years ago

So I'm working with a point light, and I'm trying to get a glowing effect that gradually changes from one color to another.

01light = script.Parent;
02r =0-- math.random (0,255)
03g = 0--math.random (0,255)
04b = 255--math.random (0,255)
05colors = {r,g,b}
06 
07function UpdateColor ()
08    light.Color = Color3.new (r/255,g/255,b/255)
09    wait (.1)
10end
11 
12while wait () do
13    print 'stage 1'
14        for i = 0,50-r do
15            if r < 255 then
View all 30 lines...

Any and all help will be appreciated.

2 answers

Log in to vote
0
Answered by
Destrings 406 Moderation Voter
10 years ago

You can, the problem is that the statement is not being executed because of

1for i = 0,50-b do

Since b = 255, 50 - 255 is -205, so for 0,-205 is not going to execute because the default step is 1

0
Thanks. It's fixed! I'm really prone to making dumb mistakes like that, haha! Maxomega3 106 — 10y
Ad
Log in to vote
5
Answered by 10 years ago

It is going to -205 because the variable b = 255...........

0
So when you do for = 1,50-b it goes to -205 fireboltofdeath 635 — 10y

Answer this question