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

Changing Fog Colour Through TextBox?

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!

3 comments

0

someone help xd

0

I made my own version and it doesn't work either...

0

rip

2 answers

✓ Accepted answer

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

10 comments

0

alot more complex than i expected

0

well uhh lemme know if it works

0

anyway upvoted

0

(larm_uh is my alt's name) error: Players.larm_uh.PlayerGui.Misc.Background.FogColour.ColourSetter:2: attempt to concatenate string with nil

0

also will that repeatedly change colour? or just for the start?

0

repeatedly

0

o

0

didnt work

2

this method would’ve worked if you didn’t try to concatenate the rgb values. Replace every ..”, “.. with ,

0

thankyou brandon. now it works and i can continue developing other parts of it

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.

1 comment

0

Upvoted. This is the perfect answer given the problem, from a user perspective having 3 textboxes like the other answer said would probably be better though

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