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

how to make an audio overlap itself?

Asked by 5 years ago

not necessarily 100% related to scripting, however, i was making an rpg-like textbox that had text grunts play as each word scrolled on the screen. it sounds choppy when you play the singular sound over and over, so, is there a way to make it play over itself?

i've been told that i could make a new instance for it, but, would that need to be parented?

this is 100% client-side, if that's important.

local function textscroll(dialogue, voice)
    if indialogue == false then
        indialogue = true
        dialoguebox.Visible = true
        for i = 1, #dialogue do
            local letter = string.sub(dialogue, i, i)
            local nextletter = string.sub(dialogue, i + 1, i + 1)
            dialoguetxt.Text = string.sub(dialogue, 1, i)
            dialoguevoice:Play() --here's the sound that is being played. its choppy when it does play
            wait()
            if (letter == "," or letter == "." or letter == "!" or letter == "?") and nextletter ~= letter then
                wait(0.2)
            end
        end
    end
end

1 answer

Log in to vote
1
Answered by
Ghusoc 50
5 years ago

I stumbled upon a post on Twitter a while ago, and it was a hacky method to do just this. It involved enabling the PlayOnRemove property and constantly setting the Sound's parent to nil, and back to its original parent again whenever you wanted it to play.

It would essentially allow the sounds to stack on top of each other, which was really nice.

0
thank you! this is very helpful! SuperKirbylover 107 — 5y
Ad

Answer this question