So i am not asking how to put a sound when u click a TextButton but like when the mouse is on it but didn't clicked.
Well, you can use MouseEnter
function provided by Roblox. It will detect whether the mouse has entered the TextButton
. Also, you can use MouseLeave
to detect if the mouse left the TextButton
.
A sample code:
-- Local Script inside the TestButton local TextButton = script.Parent local function Enter() -- Creating a local function local sound = Instance.new("Sound") -- Creates a sound object sound.Parent = TextButton sound.Name = "TestSubject" sound.SoundId = "rbxassetid://12345678" -- An example sound:Play() end local function Leave() local Sound = TextButton:FindFirstChild("TestSubject") if Sound then -- If the Sound object is found Sound:Stop() -- Stops the sound end end TextButton.MouseEnter:Connect(Enter) TextButton.MouseLeave:Connect(Leave)
Lemme know if it helps!
Closed as Not Constructive by Ziffixture
This question has been closed because it is not constructive to others or the asker. Most commonly, questions that are requests with no attempt from the asker to solve their problem will fall into this category.
Why was this question closed?