How do I make it night while inside of a part used as a region?

I am trying to make a cave and underground lab dark. All of my lighting effects still make it look bright inside.

Images

Here’s how I want them to look:

And here’s how they actually look:

I found something on Scripting Helpers, but the function provided that essentially runs the script is deprecated.

I don’t trust the toolbox, and I don’t even know what query I’d have to look up to find one, if any, to create this detail.

I barely know how to script either, mostly just basic stuff, so I have no clue where to start with fixing the script. I would very much appreciate the help.

2 Likes

In order to make this happen, the general idea is to allow the server to communicate with the client once their character has entered a certain zone. Once they have reached the zones, the server tells the respective client to adjust their lightning to dim(or to lighten up if exiting the zone).

The server is handling zone/region detections and the client(s) handle the lightning themselves. Don’t worry about any security on it(it’s highly visual).

1 Like

How would I go about doing this? As I said, I barely know how to script.

I understand what kind of logic I need to use, I just don’t know how to execute it.

1 Like

In Roblox, communication between the Server and Client is done via Remote Functions and Events (roblox.com). I would recommend reading this.

However, you should be able to complete this with just a local script. There’s a few ways you can achieve your goal. One is by checking every .RenderStepped whether the player is in a nightzone or not.

local char = nil -- Explicitly state nil for personal reasons
game.Players.LocalPlayer.CharacterAdded:Connect(function(character)
	char = character -- Update the character to the players new Char
end)
game:GetService("RunService").RenderStepped:Connect(function()
	if char then -- Make sure there IS a char to prevent errors
		local hrp = char:FindFirstChild("HumanoidRootPart") -- Find the HRP
		-- The following for-loop goes through all parts intersecting HRP
		for _, part in ipairs(workspace:GetPartsInPart(hrp)) do
			if part.Name == "NightZone" then -- Identify night-zone
				-- Place your code here for your night-effects
				game.Lighting.TimeOfDay = "22:00:00" -- Proof of concept
				return
			end
		end
		-- Your day lighting changes here
		game.Lighting.TimeOfDay = "12:00:00" -- Reset to day
	end
end)
1 Like