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

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

Asked by 5 years ago
Edited 5 years ago

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.

0
65025?? That's a little bit too much, don't you think? Miniller 562 — 5y
0
thats the issue, im only trying to set it to 255. XXXlawsonXXX 52 — 5y
0
Lol, I see Miniller 562 — 5y
0
Use game.Lighting.FogColor = Color3.new(1, 0, 1) that worked.. I don't know what causes that Miniller 562 — 5y
View all comments (6 more)
0
1, 0, 1 sets it to 255, 0, 255. this is weird XXXlawsonXXX 52 — 5y
0
Is this solved your issue? Miniller 562 — 5y
0
not exactly if i want colors like (123, 45, 67) XXXlawsonXXX 52 — 5y
0
also, (50, 50, 50) sets it to (12750, 12750, 12750) XXXlawsonXXX 52 — 5y
0
Just give me the numbers what you want Miniller 562 — 5y
0
Please accept my answer if works Miniller 562 — 5y

3 answers

Log in to vote
1
Answered by 5 years ago
Edited 5 years ago

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
Answered right as I found the solution myself, thanks! XXXlawsonXXX 52 — 5y
Ad
Log in to vote
1
Answered by 5 years ago
Edited 5 years ago

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.

0
Okay Miniller 562 — 5y
Log in to vote
-1
Answered by
Miniller 562 Moderation Voter
5 years ago
Edited 5 years ago

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

0
this changes the fogcolor to 0, 0, 0. its the same result for decimals XXXlawsonXXX 52 — 5y
0
no, this is defenitely not changes fogcolor to 0, 0, 0... Have you tried that? Miniller 562 — 5y
0
I have XXXlawsonXXX 52 — 5y
0
Is that a normal script or a local script? Where it is? Miniller 562 — 5y
0
And is there any other scripts that may block that? Miniller 562 — 5y

Answer this question