What do you want to achieve? Keep it simple and clear!
I want every text button with the buttonclick tag the play a sound on MouseButton1Down.
What is the issue? Include screenshots / videos if possible!
The script does not work. there are no error messages
What solutions have you tried so far? Did you look for solutions on the Developer Hub?
I have tried using chat gpt but that has not worked.
-- local CollectionService = game:GetService("CollectionService")
-- Define the tag you want to use
local buttonClickTag = "ButtonClick"
-- Function to handle button click
local function handleButtonClick()
game:GetService("SoundService").Click:Play()
end
-- Iterate over instances with the "ButtonClick" tag
for _, button in ipairs(CollectionService:GetTagged(buttonClickTag)) do
if button:IsA("TextButton") then
button.MouseButton1Down:Connect(handleButtonClick)
end
end