Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
2

How to make a sound play at a certain time?

Asked by
bluzorro 417 Moderation Voter
5 years ago
Edited 5 years ago
01local crickets = game.Workspace:WaitForChild("Crickets")
02local Time = game.Lighting.ClockTime
03 
04game.Lighting:GetPropertyChangedSignal("ClockTime"):Connect(function()
05    if Time == 18 then
06        crickets:Play()
07    elseif Time == 6 then
08        crickets:Stop()
09    end
10end)

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

Log in to vote
1
Answered by 5 years ago
Edited 5 years ago

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

01local crickets = game.Workspace:WaitForChild("Crickets")
02local Time = game.Lighting.ClockTime
03 
04game.Lighting.Changed:Connect(function(property) -- //Use .Changed and in (property)
05    if property == "ClockTime" then -- //Checks if changed property was "ClockTime"
06        if Time == 18 then
07            crickets:Play()
08        elseif Time == 6 then
09            crickets:Stop()
10        end
11    end
12end)
0
sorry for the delayed answer, i was at the beach. still doesn't work. bluzorro 417 — 5y
Ad

Answer this question