Hello!
After trial and error, I keep on winding up on the same spot: working code but not working ifs/thens. This code is supposed to change the color of the terrain when the TimeOfDay reaches a certain point. The ifs/thens don’t seem to be picking them up, though. The code goes as follows:
local terrain = game.Workspace.Terrain
local Time = game.Lighting.TimeOfDay
local daynight = script.Parent.DayNight.Value
local TimeOfDay = game.Lighting:GetMinutesAfterMidnight()
print(“gotpastcode3”)
local colorValue = Instance.new(“Color3Value”)
colorValue.Value = terrain:GetMaterialColor(“Grass”)
colorValue.Parent = script.Parent
print(“gotpastcode2”)
colorValue:GetPropertyChangedSignal(“Value”):connect(function()
terrain:SetMaterialColor(“Grass”, colorValue.Value)
end)
print(“gotpastcode1”)
local tweenInfo = TweenInfo.new(60, Enum.EasingStyle.Linear, Enum.EasingDirection.Out, 0, false, 0)
local Night = game:GetService(“TweenService”):Create(colorValue, tweenInfo, {Value = Color3.fromRGB(91, 122, 380 )})
local Day = game:GetService(“TweenService”):Create(colorValue, tweenInfo, {Value = Color3.fromRGB(110, 148, 70)})
print(“got past code”)
while true do
print(“Looped”)
if TimeOfDay >= 21 and daynight == 0 then
Night:Play()
print(“Tweened”)
daynight = 1
end
if TimeOfDay >= 6 and daynight == 1 and TimeOfDay <= 7 then
Day:Play()
print(“Went back”)
daynight = 0
wait(0.1)
end
wait(0.1)
end
Any help will be appreciated
Thanks,
R3M1X