Script works in studio but doesn't work in game

I have a Lights script that has to turn all the lights off in the building, it works perfectly in studio, but in game it doesn’t turn the lights off at all? All it does is create some tables and then turn some materials from Neon to Metal and Disable spotlights.
I have no idea why it doesn’t work?

Footage of in studio gameplay:

And here’s footage from in game:

The “Light script” print inside the F9 menu is from the Lights script which doesnt do its thing btw, just so you can see it works, but then it doesnt. The place is published up to date

Please help

Edit it’s a server script inside this folder and the folder is called “Building” which is inside of Workspace
I tried changing the “RunCOntext” property to Server from Legacy, it didn’t change anything:

It’s going to be pretty hard to help you without code, but maybe your problem lies in replication.

If it is a server script that dims the lights for each individual user you might wanna wait for the player to load in completely or in other words, the code runs before the player joins the game so it doesn’t affect him.

As it is just my best guess I would still strongly recommend posting a snippet of the code, you can always delete it later.

The way this works is, there are 2 scripts in Lighting, one for the cicle of day/night, and one for enabling/disabling Day Light inside the building.
I had ServerScripts running in Lighting, which worked before and always worked, but I guess it doesn’t anymore? Anyways, I moved those scripts in ServerScriptService and now everything works perfectly.

1 Like

I was kinda rushed to post this as it was a problem that persisted before and I had no idea what to do about it. To be honest I haven’t figured it out even after solving it :smile: ,only after seeing where the prints came from I realised that they worked inside ServerScriptService

Huh, that’s a weird one, I guess an update changed it? don’t ever recall trying to put scripts in lighting so I can’t confirm if it is a new thing. Anyways happy you solved it yourself.

It was a ServerScript running in Lighting which is the equivalent of a ServerScript inside of StarterGui I guess. Anyways thanks for the help polish brother!

1 Like

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.