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

How to make a sound play at a certain time?

local crickets = game.Workspace:WaitForChild("Crickets")
local Time = game.Lighting.ClockTime

game.Lighting:GetPropertyChangedSignal("ClockTime"):Connect(function()
	if Time == 18 then
		crickets:Play()
	elseif Time == 6 then
		crickets:Stop()
	end
end)

I don't get any errors, but the sound isn't playing at all. I tried it with a script aswell, but still doesn't work.

1 answer

You are checking wrong, you should check what property was changed:

local crickets = game.Workspace:WaitForChild("Crickets")
local Time = game.Lighting.ClockTime

game.Lighting.Changed:Connect(function(property) -- //Use .Changed and in (property)
	if property == "ClockTime" then -- //Checks if changed property was "ClockTime"
		if Time == 18 then
			crickets:Play()
		elseif Time == 6 then
			crickets:Stop()
		end
	end
end)

1 comment

0

sorry for the delayed answer, i was at the beach. still doesn't work.

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