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

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

Asked by 6 years ago
Edited 6 years ago

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

3 answers

Log in to vote
0
Answered by
Rare_tendo 3000 Moderation Voter Community Moderator
6 years ago
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.

Ad
Log in to vote
0
Answered by 6 years ago
Edited 6 years ago

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.

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] hiimgoodpack 2009 — 6y
0
That was a typeo, Ik what I meant. Dev_Unreal 136 — 6y
Log in to vote
0
Answered by 6 years ago

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.

Answer this question