Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

How to make it where, once a player clicks an gui, a sound plays?

The title says it, is it possible? Please post below.

3 answers

✓ Accepted answer
local button = --Button location
local sound = --sound location
local clicked = false

button.MouseButton1Down:Connect(function()
	if not clicked then
              clicked = true
              sound:Play()
        end
end)

if any errors, please mention.

This is possible, first things first is to make a gui, and design it to your preference, then insert a localscript into the gui.

local Button = --Button Destination

Now what you need to do is at in when a player clicks on the gui, music will play, what I'd suggest is adding music to "replicatedstorage"

Button.MouseButton1Down:connect(function()

       game.ReplicatedStorage.[MUSICNAME]:play()
end)

Also, make sure to add the id of the music you wish played into the properties of your sound.

If you encounter any errors, please do tell.

2 comments

0

It's ReplicatedStorage[MUSICNAME], you don't have the dot. It's like how you cannot do table.[1], you need to do table[1]

0

That was a typeo, Ik what I meant.

ScriptingHelpers is not a request site. Though I do have a script for your problem. Please consider not requesting any more on this site.

You need to have a audio/sound object under the text button. and need to add a function to it if the text button is clicked on and triggering the audio to play.

local button = script.Parent.Parent.TextButton
local audio = button.Parent.Audio

button.MouseButton1Clicked:connect(function()
	wait(.1)
	audio:Play()
end

may need to change things around to get the script working correctly.

If this worked please accept this answer. Thank you.

-Mohawkid14

Note: Remember don't ask for us to give you a script. That is violating the terms of this site.

This discussion is preserved as it was. New answers, comments, and votes are closed.