How to make sound stop?

I was creating a game, and i have certain sound play when certain event occurs (unrelated)
And i want that sound to stop before it ends by itself, so i wrote a script for that, based on what i was able to understand:

script.Parent.TimePosition = 0
wait(4)
script.Parent.Sound:Stop() 

But it doesen’t work, i would be more than grateful, if someone can tell me what i’m doing wrong.

1 Like

Script.Parent.Sound:Pause() You could try that as well

3 Likes

From what I’ve understood, the sound Instance is script.Parent, correct?

Simply do

script.Parent:Stop()

You don’t need to use a .Sound on a Sound Instance because it already knows you’re referring to what its playing.

1 Like

Is there any errors in your output? You’re referencing what appears to be a sound twice, and each of them have different paths, is that intended?

1 Like

You’re essentially referencing another sound object which most probably doesn’t exist. Your code should look like this:

script.Parent.TimePosition = 0
wait(4)
script.Parent:Stop()
1 Like
sound:Stop()
print("stop", sound.Playing, sound.TimePosition) -- stop false 0
 
wait(3)

try this!

1 Like

Turns out, since some objects weren’t created by me, i had to make small modifications to the block of code that came with the object i was giving sound to.

1 Like