So I made this little button GUI that will grow and shrink a bit when clicked on, as well as make a sound. While the former works, it only makes the sound like 80 percent of the time... is there some hidden rule about sounds that I don't know about?
local debounce = false
local p = script.Parent.Parent
function anim()
if p.Position.Y.Scale >= .75 and script.Parent.Parent.Parent.Parent.Clicked.Value == true then
p:TweenSizeAndPosition(UDim2.new(.32, 0, .17, 0), UDim2.new(.49, 0, .74, 0), 'Out', 'Linear', .05) --Making the button slightly bigger when clicked
end
local sound = p.Parent.Parent.Parent.Parent.Sound.Button.Button1 --I have a template sound stored so that I can edit it as I wish
local newSound = sound:Clone()
newSound.Parent = script.Parent
newSound.Volume = sound.Parent.Value * sound.Volume
newSound:Play()
wait(.05)
if p.Position.Y.Scale <= .75 and script.Parent.Parent.Parent.Parent.Clicked.Value == true then
p:TweenSizeAndPosition(UDim2.new(.3, 0, .15, 0), UDim2.new(.5, 0, .75, 0), 'Out', 'Linear', .05) --Shrinking it back down .05 sec later
end
repeat wait() until newSound.IsPlaying == false
newSound:Destroy() --Destroy the sound when it's finished playing
end
script.Parent.MouseButton1Up:connect(function()
if debounce == false then
debounce = true
anim() --Firing the above function
script.Parent.Parent.Parent.Parent.Click.Value = 1
end
repeat wait() until script.Parent.Parent.Parent.Parent.Click.Value == 0
debounce = false
end)

2 comments
What's the sound.Parent.Value?
On line 11, change it to 'newSound.Volume = volumenumber' instead of all of those multiples and values. It's much easier and works the same way. And it may be the solution for your cause.