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

How do I make it so sounds don't get cut off when the same sound plays again?

Asked by 6 years ago

So I have an animation being played on the character, and when a certain keyframe has been reached, it plays a sound. Since there are many key frames that play the same sound, the sound plays repetitively. The problem is that the sound currently playing gets cut off when the sound plays again. If you don't understand what I'm talking about, I'll post two examples.

This is what I want it to sound like: https://instaud.io/13ge

What it really sounds like in game: https://instaud.io/13gf

As you can see, with the second audio the sound gets cut off when the same sound plays again.
Also, here is the script I made just in case:

local player = game.Players.LocalPlayer
local char = player.Character
local animation = script.fight

animation:Clone().Parent = char.Humanoid

wait(1)

local animTrack = char.Humanoid:LoadAnimation(animation)
animTrack:Play()

animTrack.KeyframeReached:connect(function(slash)
    script.slash:Play()
end)

0
I believe the problem you are having, is that sounds can only play once at a time. Try copying 'script.slash' and playing that instead Bellyrium 310 — 6y
0
I'm confused, what do you mean by copy "script.slash"? flufffybuns 89 — 6y

1 answer

Log in to vote
2
Answered by
Bellyrium 310 Moderation Voter
6 years ago
Edited 6 years ago
local player = game.Players.LocalPlayer
local char = player.Character
local animation = script.fight

animation:Clone().Parent = char.Humanoid

wait(1)

local animTrack = char.Humanoid:LoadAnimation(animation)
animTrack:Play()

animTrack.KeyframeReached:connect(function(slash)
    local clone = script.slash:Clone()
    clone.Parent = script
    clone:Play() --*
end)

look at the sound instance like a CD player. It can only play one track at a time. So if you want to listen to multiple sounds at once, you need more cd players. the line marker --* was changed to make a copy of the sound and play it instead

0
It didn't work. It didn't play the sound, nor did it clone it. It doesn't say any error in the output either... Maybe this is a problem because you didn't do "Clone().Parent ="? flufffybuns 89 — 6y
0
Forgot to re-parent the clone. Bellyrium 310 — 6y
0
Hey, thanks. You solved my problem, and I wish there was an easier way to do this but this is gotta be it for now. Thanks! flufffybuns 89 — 6y
Ad

Answer this question