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

How do you make every single button have a sound?

Asked by
danklua 72
3 years ago

The title explains it.. i would like to have some help with this please! Some examples of games with this is.. https://web.roblox.com/games/4983678402/ , and https://web.roblox.com/games/5108696463/

--Not including this with every single gui you make--
script.Parent.Sound:Play()

also: (Without scripting every gui) (Including roblox core ui buttons)

Hopefully somebody could help me with this .. thank you!

2 answers

Log in to vote
0
Answered by
Dexiber 272 Moderation Voter
3 years ago
Edited 3 years ago

put the code below in a local script inside of a screen gui.

for _, v in pairs(script.Parent:GetDescendants()) do
    if v:IsA("TextButton") then
        v.MouseButton1Click:Connect(function()
            sound:Play()
        end)
    end
end

hope this helps, and remember do not put this inside of a textbutton or any other object, just a local script inside of the screen gui.

0
What I ment was a script that find every single button in-game and when you click it it plays a sound including the core ui danklua 72 — 3y
0
@Meltronics oh ok! I will update the script. Dexiber 272 — 3y
0
Thank you!! Just sorry to bother you again is there a way that you just put the script in StarterGui and it would do something like :FindFirstChildOfClass("ScreenGui"):FindFirstChildOfClass("TextButton").MouseButton1Click:Connect(function() danklua 72 — 3y
0
you can! just simply add the script inside of the starter gui and dont edit anything. Dexiber 272 — 3y
View all comments (2 more)
0
could you write the script because i might mess it up danklua 72 — 3y
0
No, just move it into startergui and thats all. Dexiber 272 — 3y
Ad
Log in to vote
0
Answered by
iivSnooxy 248 Moderation Voter
3 years ago

Simple, Just follow this script! Please accept and upvote if helped!

script.Parent.MouseButton1Click:Connect(function()
    sound:Play
end)

Answer this question