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

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

Asked by 3 years ago
Edited 3 years ago

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

Log in to vote
0
Answered by 3 years ago
Edited 3 years ago

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

0
Its still not working :| . The problem is from the If statement. I hope you can figure out whats wrong with this script! Glitxhxd 6 — 3y
0
What's your error? That'd prob be helpful to know lmao DietCokeTastesGood 111 — 3y
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 DietCokeTastesGood 111 — 3y
Ad

Answer this question