Music system is not working

So, i’ve made a script that turns off the music in the night, and turns it on in the day, and it’s doesnt seem to work well. Turning it on works, but turning off doesn’t. Here’s my script:

local lighting = game:GetService("Lighting")
local musicon = 6.5*60
local musicoff = 18.5*60
local music = script.Parent.Chill
lighting:GetPropertyChangedSignal("ClockTime"):Connect(function()
	if lighting:GetMinutesAfterMidnight() > musicon and lighting:GetMinutesAfterMidnight() < musicoff then
		if music.Playing == false then
			music:Play()
		end
	elseif lighting:GetMinutesAfterMidnight() > musicoff and lighting:GetMinutesAfterMidnight() < musicon then
		script.Parent.Chill:Destroy()
	end
end)
2 Likes

You’re… deleting the sound immediately. Just use music:Stop().

4 Likes

Even if i use

script.Parent.Chill:Stop()

it still doesn’t stop.

3 Likes

Perhaps try printing :GetMinutesAfterMidnight and adjust your Script there. You might just be inputting some values wrongly.

7 Likes

It’s working after I printed a message and changed one thing, I don’t really know how! But thank you for help!

4 Likes

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.