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

How to make the sound play after the player clicks the button? [EASY!]

Asked by 4 years ago

I need the sound to also play when they click to close the gui

function close()
script.Parent.Parent.Parent:Remove()
end

script.Parent.MouseButton1Click:connect(close)
game.StarterGui.Menu.click:Play() -- the sound

0
Just a heads up, you never address the StarterGui, since that stuff automatically gets cloned to the PlayerGui, and thats where you see it. DarkDanny04 407 — 4y

3 answers

Log in to vote
0
Answered by 4 years ago

Like what @DarkDanny04 said, you do not use starter gui because that stuff gets cloned into the player gui.

try this:

function close()
    script.Parent.Parent.Parent:Remove()
end

script.Parent.MouseButton1Click:connect(close)
game.Players.LocalPlayer.PlayerGui.Menu.click.Play()

0
It did not work JuzeyPlayz -83 — 4y
0
:Play() - Sound Instances can only be heard in physical environments; you must have it in workspace. :Remove() is deprecated too, use :Destroy(). Ziffixture 6913 — 4y
0
:Remove() is deprecated, use :Destroy(). Lowercase :connect is deprecated, use :Connect(). Ziffixture 6913 — 4y
Ad
Log in to vote
0
Answered by 4 years ago

try this! (I am a newbie at Scripting) put your sound or whatever in SoundService and then put this code

game.SoundService.YourSound.Playing = true

ReplaceYourSound with the name of the sound you want, and again I am a newbie and sometimes I just do the simplest things there maybe better scripts than this, but this is all I have to offer.

0
Does this worK? iivSnooxy 248 — 4y
Log in to vote
0
Answered by 4 years ago
function close()
    script.Parent.Parent.Parent:Destroy() -- Remove() is deprecated so use :Destroy()
end

script.Parent.MouseButton1Click:Connect(close) -- a lowercase c in Connect makes the function deprecated so please capitalize the C
game.Players.LocalPlayer.PlayerGui.Menu.click:Play()

If it doesn't work, at the end of the script, try adding a wait() time for however long the song is.

Answer this question