Hey there! I’ve recently tried to script a button where a random sound from a list would play, each time it’s pressed. I created a list of three sound effects, defined services and variables, etc, but I’m really stuck on how to actually execute my code when the button is clicked. Here’s my full button script below;
--Call Roblox SoundService
local soundService = game:GetService("SoundService")
--Define Parent Button
local btn = script.Parent
--Define Individual Sounds
local relayClicks4_SFX = soundService["Relay Clicks 4 (SFX)"]
local relayClicks9_SFX = soundService["Relay Clicks 9 (SFX)"]
local relayClicks17_SFX = soundService["Relay Clicks 17 (SFX)"]
--Define Further Variables
local soundList = {relayClicks4_SFX, relayClicks9_SFX, relayClicks17_SFX}
--Execute Selection Code
--??? ??? ???
As you can see, I have everything defined, but I just can’t quite put it together. I would appreciate some help on the last part of my script!