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

Script that makes the music change when its day or night dosen´t work?

hello my name is yakao I made a script that makes the music change when its day or night the problem is that it won't play any music here is some detail: if game.Lighting.TimeOfDay (00) then workspace.Night.Night:Play() workspace.Day.Day:Stop() end if workspace.game.Lighting.TimeOfDay(10) then workspace.Day.Day:Play() workspace.Night.Night:Stop() end ( This script needs to work for the 2016 version of Roblox studio )

1 answer

✓ Accepted answer

TimeOfDay is a property, to check if a property is equal to something, you use ==, >=, <=, > or <.

Unfortunatly TimeOfDay is hard to read out in a script as it's a string with H:M:S, lucky for us there's ClockTime now, which is a simple number instead.

You can do the following.

-- This event fires every time a property of lighting is changed.
game.Lighting.Changed:Connect(function() 
	if game.Lighting.ClockTime >= 10 then
		--Play day music
	else
		--Play night music
	end
end)

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