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
4 years ago
Edited 4 years ago
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

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

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)
0
sorry for the delayed answer, i was at the beach. still doesn't work. bluzorro 417 — 4y
Ad

Answer this question