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

How to stop a sound file while it's playing?

Asked by 5 years ago

I'm trying to insert sound effects for my game and i found a good one created by Roblox. The problem is the sound effect i need is at the beginning of the sound file and not the full sound file. I know i can record the part that i need, but i'm afraid that's copyright since it's one of the songs Roblox got from APM Music in their contract. If there's no way possible, could you recommend me a software to make custom sounds

1 answer

Log in to vote
1
Answered by 5 years ago
Edited 5 years ago

Use the stop method along with the IsLoaded property so it doesn’t stop where you don’t want it to stop.

Say, there’s a sound in workspace called Sound1 and I wanted to stop it after 5 seconds, this is how I do it:

local sound = workspace:WaitForChild(“Sound”)
function StopSound()
sound:Play()
if sound.IsLoaded == true then

wait(5)
sound:Stop()
end
end

Hope this helps!

0
Remember to also have something to trigger the function so it runs. Syntax_404 37 — 5y
0
You can also check the TimePosition Bertox 159 — 5y
Ad

Answer this question