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

Help Color3 Problems?

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

1 comment

0

You're welcome!

3 answers

✓ Accepted answer

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!

1 comment

0

thanks :)

Refer to this or this.

3 comments

0

Lol, too lazy to type another one again? Yeah, it's long. I would just copy and paste :\

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.

0

This question is everywhere. I even asked this question when I was a scripting noob(Didn't know wiki existed back then)

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

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