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

Help Color3 Problems?

Asked by 9 years ago

When i want to do a color3 on my games to color like fog color it turns into something else even though i put it in the fog color it becomes something else like the color white instead of the color i wanted.

Skills = {"Silence"}
while true do
SkillInUse = Skills[math.random(1, #Skills)]
cooldown = math.random(10,20)
wait(cooldown)
if SkillInUse == "Silence" then
    game.Workspace.ShadowScream:Play()
    game.Lighting.FogEnd = 50
    game.Lighting.FogColor = Color3.new(0,0,0)
    wait(15)
    game.Lighting.FogEnd = 150
    game.Lighting.FogColor = Color3.new(161, 161, 161) -- problem
end
end
0
You're welcome! EzraNehemiah_TF2 3552 — 9y

3 answers

Log in to vote
0
Answered by 9 years ago

Color3 has only 2 values. 1 and 0. 0,0,0 is black 1,1,1 is white 1,0,0 is red and etc. So why do we use 255? It isn't supposed to be. So to make it not white we need it to be a decimal number. Imagine something 255 times brighter than white. Exactly. So we need to get 161 and divide it by 255.

Skills = {"Silence"}
while true do
SkillInUse = Skills[math.random(1, #Skills)]
cooldown = math.random(10,20)
wait(cooldown)
if SkillInUse == "Silence" then
    game.Workspace.ShadowScream:Play()
    game.Lighting.FogEnd = 50
    game.Lighting.FogColor = Color3.new(0,0,0)
    wait(15)
    game.Lighting.FogEnd = 150
    game.Lighting.FogColor = Color3.new(161/255, 161/255, 161/255) --"/" means divide.
end
end

Pretty simple. Hope it helps!

0
thanks :) Anthony9960 210 — 9y
Ad
Log in to vote
2
Answered by
Redbullusa 1580 Moderation Voter
9 years ago

Refer to this or this.

0
Lol, too lazy to type another one again? Yeah, it's long. I would just copy and paste :\ EzraNehemiah_TF2 3552 — 9y
0
Actually, I've referred to these links because a) you can find this topic in ScriptingHelpers because the question is already answered elsewhere, and b) this topic is research-able and can be located easily in Wiki. Redbullusa 1580 — 9y
0
This question is everywhere. I even asked this question when I was a scripting noob(Didn't know wiki existed back then) EzraNehemiah_TF2 3552 — 9y
Log in to vote
1
Answered by 9 years ago

Hello.

The reason it doesn't work properly is because Color3 takes either a decimal or a fraction.

Wrong way:

Color3.new(161,161,161)

Right way:

Color3.new(161/255,161/255,161/255,)

Fixed Version of your code:

Skills = {"Silence"}
while true do
    SkillInUse = Skills[math.random(1, #Skills)]
    cooldown = math.random(10,20)
    wait(cooldown)
    if SkillInUse == "Silence" then
        game.Workspace.ShadowScream:Play()
        game.Lighting.FogEnd = 50
        game.Lighting.FogColor = Color3.new(0,0,0)
        wait(15)
        game.Lighting.FogEnd = 150
        game.Lighting.FogColor = Color3.new(161/255, 161/255, 161/255) -- problem
    end
end

Answer this question