I’m working on a game where a player is trapped in a sinking ship, and at one point in the game I am gonna have them enter a room and the power goes out for a few seconds. So far the script seems to work fine, but then the power comes back on and my games lighting looks wonky as if the brightness of the lights was turned up. Here is a video of it occuring you’ll notice everything is way too bright when the lights come on robloxapp-20200725-1115475.wmv (3.2 MB) I checked the properties of the lights themselves and their brightness hasn’t been altered, I don’t see anything that would be wrong as you’ll see all my script changes in terms of the lights is whether or not their enabled, and the material of them. I can’t find any solutions anywhere and I have no clue what could be causing this, my best guess is if it’s my fault it would have to be somewhere in the code, which you can see here
Before I even start working on helping with the lighting, this code needs some serious reformatting. You can do this by using for loops and concatenating the index, like so:
local grandparent = script.Parent.Parent
local lightArray = {}
local buttonPressed = false
for count = 1, 7 do
table.insert(lightArray, count, grandparent:FindFirstChild("L" .. count))
end
script.Parent.Touched:Connect(function(hit)
if buttonPressed then return end
buttonPressed = true
for i, light in pairs(lightArray) do
light.Bulb.PointLight.Enabled = false
light.Light.Material = "Marble"
end
game.Lighting.OutdoorAmbient = Color3.new(0,0,0)
game.Workspace.PD:Play()
wait(game.Workspace.PD.TimeLength)
for i, light in pairs(lightArray) do
light.Bulb.PointLight.Enabled = true
light.Light.Material = "Neon"
end
game.Lighting.OutdoorAmbient = Color3.new(143,143,143)
game.Workspace.PU:Play()
wait(.1)
script.Parent:Destroy()
buttonPressed = false
end)
Also, please, name your variables something descriptive! From your code, I can see that each lights hierarchy looks something like:
The bulb has the pointlight but it is the glass that surrounds the light, and then the light is a part that is neon to give off the turned on light effect, Sorry about that being not very clear. I’m very inexperienced when it comes to scripting, hence the lackluster code, I replaced mine with your fix up and the lighting still got messed up, so the weird lighting can’t be a problem with the coding right? Here you can see the result is the same with your variation of the code
I can’t figure out screenshotting the properties, so I’ll list them off for your I guess,
Color: Institutional White
Cast Shadow = true
Material: Neon
Reflectance and transparency = 0
Anchored archivable and cancollide are all true
and it’s collision fidelity is a box
also it is a meshpart
I’ve checked and none of the scripts in my game other than the one shown above affect lighting, however as you see the script is supposed to set the OutDoorAmbient back to 143,143,143 but for some reason I looked and after the script runs the OutdoorAmbient is set to 36465, 36465, 36465. What could be causing this? The script says nothing about those numbers what so ever.
I just realized what’s wrong: Roblox developer page on Color3. Color3.new() accepts values from 0 to 1 while Color3.fromRGB() accepts values from 0 to 255. Just replace Color3.new with Color3.fromRGB.