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

How do you make it like tanks have firing sounds?

Asked by 7 years ago

Like for example when i fire it the audio plays then fades.

0
I don't know how to do this, however it'd definitely involve something like MouseButton1Click:Connect() o_Blyzo 12 — 7y
0
The audio needs to be parented to a base part for it to be 3D sound. User#5423 17 — 7y

1 answer

Log in to vote
0
Answered by
sad_eyez 162
7 years ago
Edited 7 years ago
-- Something like this
-- I would probably make with a click detector

local debounce = false

script.Parent.mouseClick:connect(function()
    if debounce == true then -- keeps people from pressing it constantly
        return
    end
    debounce = true
    local audioID = "rbxassetid://258057783"
    local audio = Instance.new("Sound", game.Workspace)
    audio.SoundId = audioID
    audio:Play()
    for i = 10,0,-1 do -- where it starts fading
        wait(0.3)
        audio.Volume = audio.Volume -0.1
    end
    wait(3)
    audio:Stop()
    audio:Destroy() -- Destroys so it doesn't duplicate over and over everytime you click
    debounce = false
end)
Ad

Answer this question