Hello , I'm trying to make something disappear and when it disappear , it's has to make a noise (soundid) , somebody did this script for me but it's not like I want , it's not making sound , it's not making it disappear .
function x(hit) script.Parent.Anchored = false script.Parent.GlassSound:Play() script:Destroy() end script.Parent.Touched:connect(x)
Hope somebody can help me :/ Thanks
First off, how long does the sound to be fully played once? Because if you play it, and immediately destroy it immediately without delay the sound gets destroyed as well.
I think you should adjust the script to this:
function x(hit) script.Parent.Anchored = false script.Parent.GlassSound:Play() wait(5) script.Parent:Destroy() end script.Parent.Touched:connect(x)
I took a total of 5 seconds, but put in any number depending on how long the sound's duration is. Making no promise that it works, but it may. Goodluck further on.
Thanks for the reply , Unfortunatly it doesn't work :/ and the script doesn't make my brick disappear oof , I'm still hoping that somebody knows how to help me .
connect() is deprecated, use Connect():
function x(hit) script.Parent.Anchored = false script.Parent.GlassSound:Play() script:Destroy() end script.Parent.Touched:Connect(x)
That has to be your problem. Also, in line 4, this...
script:Destroy()
...is similar to this...
script.Disabled = true
...without having to destroy the Script. This is COMPLETELY your choice and I'm not forcing you to do this. I'm just giving you a suggestion.
The answer is very very simple. You don't even need a script for it. The sound object has a property called 'PlayOnRemove'. Simply check the box and it will play if the sound or the parent of the sound is destroyed. I suppose that that is what you wanted.