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

Why can't I change the Lighting properties?

while game.waitForChild("Lighting") = false do wait() end
script.Parent.FogStart = 0
script.Parent.FogEnd = 250

Just trying to change the property of fog. 4 I thought the reason why it wasn't working was because I didn't wait for the lighting to be loaded into the game ( that's why I have that first line )? Not sure if that would even be an issue.

Honestly stuck, and my last thought is maybe it's because of filtering enabled? I don't have a strong grasp on FE yet, so if that's the problem then I definitly need a good explanation.

2 answers

✓ Accepted answer

Hi! FE problems normally arise when you work with GUIs or LocalScripts. Shouldn't be the case here.

Problems with your code:

  1. In a while or if statement, use ==. == is compare, = is assign this to a variable

  2. When calling functions, (for example, WaitForChild() ), you have to use : not .

  3. Also, its WaitForChild("Lighting").

  4. Don't use WaitForChild() like that. It already waits for it, so you don't need more wait() statements.

Tip: use autocomplete in the editor, it will avoid lots of small errors.

So here's a (hopefully) fixed version of your code:

game:WaitForChild("Lighting")
script.Parent.FogStart = 0
script.Parent.FogEnd = 250

If you want to make your code shorter, and less repetitive (better to edit later on), you can also do this:

l = game:WaitForChild("Lighting")
l.FogStart = 0
l.FogEnd = 250

Hope it helps.

3 comments

0

Sorry for the essay.

0

Technically, game.WaitForChild can work like this game.WaitForChild(game,'Service_Name') or any other functions in that matter.

0

Don't mind the essay! The more information the better. Thanks.

  1. Please use the output and script analysis located under the view tab.

  2. The condition used in the while loop is not a condition. Furthermore, if you're trying to get lighting. You can yield a script by using a loop properly.

local lighting;
repeat 
	lighting=game:GetService('Lighting');
	wait();
until lighting; -- I am using a repeat loop.

1 comment

0

Feedback was really appreciated, thank you!

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