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

Part of the code works in one spot and not the other, how do I fix this?

Light = game.Workspace.Lamp.LightPart
Time = 0

while true do
	Time = Time+4
	game.Lighting:SetMinutesAfterMidnight(Time)
	wait(.1)
	
	if game.Lighting:GetMinutesAfterMidnight == 6 * 60 then
		Light.Material = Enum.Material.Plastic
		Light.PointLight.Enabled = false
	end 
	if game.Lighting:GetMinutesAfterMidnight == 18 * 60 then
		Light.Material = Enum.Material.Neon
		Light.PointLight.Enabled = true
	end
end

That's the code I'm using to turn a lamp on and of at certain times in the day but in the first "if then" statement "==" cause an error because it expects a ( or { how do I fix this (And yes the is the Wiki's Tutorial day/night script).

1 answer

You need to write "GetMinutesAfterMidnight()" because it is a function, and you always put open and close brackets after the name when calling it. Inside the brackets, you would pass it an argument (Either nothing or Time in your case), so the function knows what its doing.

2 comments

0

Then why did it work in the 2nd function?

0

What does the output say?

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