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

Why is fogcolor becoming extremely intense when I set it with a script?

When I attempt to change game.Lighting.Fogcolor with a script the color3 values change to 65025.

Like if were to do this:

game.Lighting.FogColor = Color3.new(255, 0, 255)

The color 3 will change to 65025, 0, 65025 and create an extremely intense fog the same color as intended (in this case magenta).

I'm not sure if this is a bug as it only recently started happening in my game. It would be great if anyone knows how to fix this. Thanks in advance.

10 comments

0

65025?? That's a little bit too much, don't you think?

0

thats the issue, im only trying to set it to 255.

0

Lol, I see

0

Use game.Lighting.FogColor = Color3.new(1, 0, 1) that worked.. I don't know what causes that

0

1, 0, 1 sets it to 255, 0, 255. this is weird

0

Is this solved your issue?

0

not exactly if i want colors like (123, 45, 67)

0

also, (50, 50, 50) sets it to (12750, 12750, 12750)

0

Just give me the numbers what you want

0

Please accept my answer if works

3 answers

✓ Accepted answer

The issue in this code is that Color3.new() expects numbers ranging from 0-1. Most people write in RGB values (0-255), so if you want to continue to do that, you can either divide each value by 255 or use Color3.fromRGB().

game.Lighting.FogColor = Color3.fromRGB(255,0,255)

or

game.Lighting.FogColor = Color.new(1,0,1) --because 255/255 is 1

Your intensity issue is probably being caused by something else, however. Check your FogEnd property and see if it's too low!


##Resources:

Color3


##Accept and upvote if this helps!

1 comment

1

Answered right as I found the solution myself, thanks!

Ok, so after some digging on the developer wiki I have found that color3.new can only range from only 0 to 1.

Returns a Color3 with the given red, green, and blue values. The numbers can range from 0 to 1.

So instead I would have to use color3.fromRGB which can use the 0 - 255 range I was trying to use.

1 comment

0

Okay

I know it! Use this

game.Lighting.FogColor = Color3.new(123/255, 45/255, 67/255)

You can change 123, 45 and 67, and that will set FogColor to the expected numbers

5 comments

0

this changes the fogcolor to 0, 0, 0. its the same result for decimals

0

no, this is defenitely not changes fogcolor to 0, 0, 0... Have you tried that?

0

I have

0

Is that a normal script or a local script? Where it is?

0

And is there any other scripts that may block that?

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