It detects what time it is, but when paired with a day/night script will not change.
is there something I don’t have in the script to make this work?
local Clocktime = game.Lighting.ClockTime
local LightPart = script.Parent
if Clocktime <= 17 then
LightPart.BrickColor = BrickColor.new("Medium Stone Grey")
LightPart.Material = ("SmoothPlastic")
end
if Clocktime >=18 then
LightPart.BrickColor = BrickColor.new("Institutional White")
LightPart.Material = ("Neon")
end
I mean like, what type of script is the Lightning and Day/Night? Is it a LocalScript, or a server script (a regular one)? Your code seems fine, as I tested it, so it might just depend on the type of script you are using for both of the scripts.
You would have to constantly run this code over and over again as the time changes. You could use a loop to accomplish this or RunService
game:GetService("RunService").Heartbeat:Connect(function()
local Clocktime = game.Lighting.ClockTime
local LightPart = script.Parent
if Clocktime <= 17 then
LightPart.BrickColor = BrickColor.new("Medium Stone Grey")
LightPart.Material = ("SmoothPlastic")
end
if Clocktime >=18 then
LightPart.BrickColor = BrickColor.new("Institutional White")
LightPart.Material = ("Neon")
end
end)
Fixed! I needed to use a GetPropertyChangedSignal for it to work
local Clocktime = game.Lighting.ClockTime
local lightpart = script.Parent
game.Lighting:GetPropertyChangedSignal("ClockTime"):Connect(function()
local newtime = Clocktime
if game.Lighting:GetMinutesAfterMidnight() > 6 * 60 then
lightpart.Material = Enum.Material.Plastic
lightpart.BrickColor = BrickColor.new("Medium stone grey")
end
if game.Lighting:GetMinutesAfterMidnight() > 18 * 60 then
lightpart.Material = Enum.Material.Neon
lightpart.BrickColor = BrickColor.new("Institutional white")
end
end)