I am currently making IFE (In Flight Entertainment) and I decided to have a Misc. option where you can change the colour of the fog. The way I am doing this is by having a loop go off every second checking the colour. The problem is that the only colour it changes to is red. If I put 255 in the text box, it will give me red. If I put 255,255,255 in the text box I get black for some reason. It is in RGB. My local script:
while true do wait(1) game.Lighting.FogColor = Color3.new(script.Parent.Text) end
It previously was:
while true do wait(1) game.Lighting.FogColor = Color3.fromRGB(script.Parent.Text) end
Any help is appreciated!
My idea is to probably make three textboxes for red, green and blue. And then combine all the text with tonumber()
Here's a quick example on how you can combine several values:
print("test" .. 1 + 2 .. "!") --output: test3!
If you want to use this script I made, make sure your textboxes exist where the script is looking for them.
while wait() do if tonumber(script.Parent.Red.Text) and tonumber(script.Parent.Green.Text) and tonumber(script.Parent.Blue.Text) then game.Lighting.FogColor = Color3.fromRGB(tonumber(script.Parent.Red.Text) .. ", " .. tonumber(script.Parent.Green.Text) .. ", " .. tonumber(script.Parent.Blue.Text)) end end
string.split
would be very useful for this. You could take each individual number and apply it to the rgb color.
For example:
while true do wait() local rgbValues = string.split(script.Parent.Text, “,”) If tonumber(rgbValues[1] and tonumber(rgbValues[2] and tonumber(rgbValues[3] and #rgbValues == 3 then game.Lighting.FogColor = Color3.fromRGB(tonumber(rgbValues[1], tonumber(rbgValues[2], tonumber(rgbValues[3]) end end
Sorry if my spacing was a bit weird, it’s because I typed all of this on mobile. Hopefully you get the gist of it. I basically check if there are 3 numbers in the textbox by separating them from the commas in the text. Technically u should be checking if they are positive integers as well because I don’t think rgb takes negative numbers.