I’ve created a button click sound that plays whenever a button on the GUI is clicked. When I test it both in-game and in studio it sometimes plays the full clear sound, sometimes plays half of the sound, and sometimes it plays nothing/barely can hear it. The sound is 0.066 seconds long and here is my code:
(localscript)
local soundService = game:GetService("SoundService")
wait(5) -- gui to load
for _, x in pairs(game.Players.LocalPlayer:WaitForChild("PlayerGui"):GetDescendants()) do
print(x.Name)
if x.ClassName == "TextButton" or x.ClassName == "ImageButton" then
x.MouseButton1Down:Connect(function()
print("Sound playing")
game.ReplicatedStorage.ButtonDown:Play()
end)
end
end
Should I edit the sound to make it longer, or perhaps the code can be written better to make the sound more consistent? Or something else?