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

How do I make a sound continuously play when pressing keys?

Asked by 3 years ago
Edited 3 years ago

can someone help me how I can have a sound continuously playing when pressing keys

function inputStart(obj, gameProcessed, plr) 
    if gameProcessed then return end
    local equiped = player.Character:FindFirstChild(script.Parent.Name)
    if obj.KeyCode == Enum.KeyCode.W then
        if equiped then        
            Up:Play()
            Left:Stop()
            Down:Stop()
            Right:Stop()
            script.Parent.Sound:FireServer() -- Sound Plays
            wait(.5)
            script.Parent.SoundStop:FireServer() -- Sound Stop
        end
    elseif obj.KeyCode == Enum.KeyCode.A then
        if equiped then
            Left:Play()
            Up:Play()
            Down:Stop()
            Right:Stop()
            script.Parent.Sound:FireServer() -- same Sound Plays
            wait(.5)
            script.Parent.SoundStop:FireServer() -- same Sound Stop
-- Code that continues... It's the same thing
        end

Whenever .5 ends, the sounds just have a seizure when I spam keys. I need to find out how to reset wait() or keep the sound playing when spamming keys

1 answer

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

If you go to 'Properties' in the Sound, you have an option called 'Loop'. Enable the loop option to continuously play the sound when enabled.

0
It's not loop. did forget to mention that whenever you press those keys the volume goes to 1 for 0.5 seconds to 0. I want to reset that timer so it doesn't freak out from 0.5 to 0 when you spam keys. TheBuliderMC 84 — 3y
Ad

Answer this question