So, I'm pretty new to Lua and I've been trying to make it to where if a player touches any of the parts that are inside of dayArray, the time will become 12 * 60, and if they touch any of the parts inside of nightArray, the time will become 20 * 60.
However, I'm running into a problem I'm unsure how to resolve. I'm getting an error when I try to run Touched, so I'm wondering what I can do to fix this.
Here's the code:
local dayArray = {game.Workspace.DayParts.Part1, game.Workspace.DayParts.Part2}
local nightArray = {game.Workspace.NightParts.Part1, game.Workspace.NightParts.Part2}
function setDay(part)
game.Lighting:SetMinutesAfterMidnight(12 * 60)
end
dayArray.Touched:connect(setDay)
function setNight(part)
game.Lighting:SetMinutesAfterMidnight(20 * 60)
end
nightArray.Touched:connect(setNight)
An explanation of what I'm doing wrong and how to fix it would be nice. Thanks.

1 comment
Why not do "game.Workspace['ASSET']:GetChildren()" instead of doing lines 1 & 2 like that? :P