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

How to make something disappear and make a sound ?

Asked by 5 years ago

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

4 answers

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

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.

Ad
Log in to vote
0
Answered by 5 years ago

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 .

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

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.

Log in to vote
0
Answered by
noammao 294 Moderation Voter
5 years ago
Edited 5 years ago

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.

0
he is also looking to unanchor the part and i don't think you noticed that DeceptiveCaster 3761 — 5y
0
I don't wanna unachor it but like that the brick fall to the void when somebody touch it and that when I touch it there is a sound User#22475 0 — 5y
0
So just to clarify. When a player touches that specific brick the brick makes a sound and falls down through the ground? noammao 294 — 5y

Answer this question