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.
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).
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)