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

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

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

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

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