So I want to make a UI that is mostly white to transition to a darker color when the player is in a darker area. I am not fully sure how to go about doing this…
Does anyone know how to kind of take the players screen and see if it’s generally dark or bright?
Using LocalScripts, you’re able to transform the game’s world space and lighting like you would any other script. The only difference is that anything you do on a LocalScript will not be replicated to the server and hence not to any other players. This means LocalScripts can’t be used to make things like Parts change, but can be used to your advantage with things like Lighting.
Take the Ambience setting of Lighting for example, the general hue of the workspace. We could set this value to something else on a LocalScript, which means that the player will have their Ambience changed, but no one else would see this affect. Therefore, by changing the Ambience on a LocalScript you could individually change the Lighting characteristic for a specific player without affecting anyone else.
Oh no, I think you misunderstood. I do not intend to change the lighting for the player, I want to know the lighting of the player. For example, if they walk into a dark cave, I want to know they are in a dark area so I can make the UI lighter in color so they can see. If they are outside in a bright area, I want to know to make the UI darker for them to see.
You can try using Region3 instead of finding the camera’s brightness. Or, a part with a Touched event on it, but I don’t think that’s reliable. So you’re better off with using Region3.
Also, Region3 isn’t only terrain, Region3 gets a specific area by using positions. You can script it so it gets everything in that region. Then you could script it so it turns down the lighting when a player has got in the region.
I am sorry, it seems you are misunderstanding what I am trying to do. I am not trying to change the lighting of anything. I have a UI that is white-colored. I want the UI to become darker in color when the player is in bright areas so they can see the UI elements. When the player is in darker environments, I want the UI to become brighter in color so the player can see the UI elements in the darkness.
Try using raycasting to check if there is something above them and see what material it is.
Old trick I did was I made invisible bricks that were the only things to get hit by the cast and would have a name to say what it was. If the raycast detects something that looks like a cave, they are likely in a cave.
You can also create regions with bricks or region3 and check if the player is inside one of them. This is really the only way I guess you could “detect” brightness without doing something like manually detecting how much light from light sources is available where the character is (which is pretty computationally intensive and complicated).
The cave was simply an example to help people understand what I am trying to do. I found a answer on the Unity 3D answer site… I think I can try to make it work out in Roblox. If anyone has any suggestions though, I would love to hear them.
Well like I said before, that is my second suggestion but that leads to so many problems:
Ray can hit something like decorations on the map and invisible bricks
Different light types shine and spread in different ways
Cant ignore sunlight and ambient light
In a well lit room, there will most likely be several light sources
Light can go through transparent objects
Thats why i still recommend the easy solution of just creating bricks at the top or bottom of the area that are invisible and can be used to signify if dark/light mode should be enabled via a raycast to them. You can manipulate them in realtime too if you wish to have lights turn on and off. You can also union them together or group them and check their parent’s name (what I did).