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

How would I make a sound play at a certain ingame time?

Im trying to make a sound play when the ingame time hits 6.

local Time = game.Lighting.ClockTime
local Chime = script.Parent.Sound

game.Lighting.Changed:Connect(function(property)
	if property == "ClockTime" then
		if Time == 6 then
			Chime:Play()
		end
	end
end)

This is what I've got right now!

1 answer

✓ Accepted answer

Add a print('hit 6') after if time == 6.

Your problem might be that it skips over 6 because of how precise that is. You could instead do this:

game.Lighting:GetPropertyChangedSignal("Time"):Connect(function()
	if game.Lighting.Time >= 5.9 and game.Lighting.Time <= 6.1 then 
		Chime:Play()
	end
end)

*fixed

3 comments

0

Its still not working :| . The problem is from the If statement. I hope you can figure out whats wrong with this script!

0

What's your error? That'd prob be helpful to know lmao

0

I fixed it for you, it wasn't that hard since I forgot one thing. I don't know why you needed me to do that since it wasn't that complicated lol

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