Hello! So I am making a Script where when I hover over a UI, it enlarges, and plays a sound, along with plays a different sound when clicked. How ever I got the Enlargement part working, the sounds seem to not play at ALL. I know they should because they are from the Toolbox where you can get Audio’s from. So I am really confused on why this won’t work.
Here is the script:
-- Change these values to match your preferences
local hoverSoundId = "rbxassetid://9043341746" -- Replace with the ID of the hover sound
local clickSoundId = "rbxassetid://987654321" -- Replace with the ID of the click sound
local scaleFactor = 1.3 -- Controls the amount the button enlarges when hovered
local tweenTime = 0.2 -- Controls the duration of the size tween in seconds
-- Get the TextButton
local textButton = script.Parent
-- Set up the hover and click sounds
local hoverSound = Instance.new("Sound")
hoverSound.SoundId = hoverSoundId
hoverSound.Volume =19
local clickSound = Instance.new("Sound")
clickSound.SoundId = clickSoundId
clickSound.Volume = 1
-- Set up the hover effect
local defaultSize = textButton.Size
local hoverSize = UDim2.new(defaultSize.X.Scale * scaleFactor, defaultSize.X.Offset * scaleFactor, defaultSize.Y.Scale * scaleFactor, defaultSize.Y.Offset * scaleFactor)
local function onHoverEnter()
hoverSound:Play()
textButton:TweenSize(hoverSize, Enum.EasingDirection.Out, Enum.EasingStyle.Quad, tweenTime, true)
end
local function onHoverLeave()
textButton:TweenSize(defaultSize, Enum.EasingDirection.Out, Enum.EasingStyle.Quad, tweenTime, true)
end
textButton.MouseEnter:Connect(onHoverEnter)
textButton.MouseLeave:Connect(onHoverLeave)
-- Set up the click effect
local function onClick()
clickSound:Play()
end
textButton.MouseButton1Click:Connect(onClick)
Any help?
It is a Local Script, and is a Child of the Textbutton