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

attempt to perform arithmetic on field 'FogColor' (a userdata value) can anyone fix this?

Asked by 9 years ago

I'm new to scripting and I was attempting to change the fogcolor and I got a error message as shown on the title and I don't know what I did wrong and I don't know how to fix it! can anyone please explain how to fix this?

for i = 1,10 do
    wait(1)
    game.Lighting.FogColor = game.Lighting.FogColor - Color3.new(1,1,210/210)
end

1 answer

Log in to vote
2
Answered by 9 years ago

Your problem is you're trying to subtract colors: it's not possible. You can, however, get the values of individual colors used to create the color3 value, and then subtract from those and compile them into a new color3value to change the fog color.

for i = 1,10 do
local lighting = game.Lighting
local r = lighting.FogColor.r --numvalue for red
local g = lighting.FogColor.g --numvalue for green
local b = lighting.FogColor.b --numvalue for blue

lighting.FogColor = Color3.new(r - 1, g - 1, b - 210/210)
end
Ad

Answer this question