Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

Day/Night for neon lights...Help?!

I created some neon parts for some stairs and I grouped them into a model called "Yellow leds" in a Union called "Staircase". ** I have two staircases. **They were supposed to turn a different color at certain times; however I keep getting this error:

11:12:57.765 - ServerScriptService.Day/Night:12: attempt to call method 'IsA' (a nil value)

This is the script I made. Using tables, I put the leds for both staircases so that they both change colors at a certain time. I then tried to use ipairs to get all the children of "Yellow leds", which are the neon parts. Please help!

leds1 = game.Workspace.Staircase["Yellow leds"]:GetChildren()
leds2 = game.Workspace.Staircase2["Yellow leds"]:GetChildren()
leds = {leds1,leds2}
minutesAfterMidnight = 0
while true do
	minutesAfterMidnight = minutesAfterMidnight + 10
	game.Lighting:SetMinutesAfterMidnight(minutesAfterMidnight)
	wait(.1)

	if game.Lighting.TimeOfDay == "06:00:00" then
		for i,v in ipairs(leds) do
			if v:IsA("Part") then
				v.BrickColor = BrickColor.new("Deep blue")
				end
			
			end
		end


	if game.Lighting.TimeOfDay == "18:00:00" then
		for i,v in ipairs(leds) do
			if v:IsA("Part") then
				v.BrickColor = BrickColor.new("Bright Yellow")
				end	
			end
		end
	end


1 answer

✓ Accepted answer

v is a table. You need to iterate over every table in your table. You see how leds contains leds1 and leds2? At every iteration, v is either leds1 or leds2

if game.Lighting.TimeOfDay == "06:00:00" then
        for i,t in ipairs(leds) do
		for k,v in next, t do
           	 if v:IsA("Part") then
     	           v.BrickColor = BrickColor.new("Deep blue")
     	        end
		end
        end
end

1 comment

0

Thank you!

This discussion is preserved as it was. New answers, comments, and votes are closed.