UIPageLayout play a sound on every scroll?

Title. Looking to see if there is “OnScroll” or something for UIPageLayout so that when scrolling through a set of buttons it makes a sound after every time it scrolls to the next one. Not sure if I just missed it on its respective reference page but I’d like to know if it’s possible.

I still need help with this problem

i never used UIPageLayout but looking at the wiki i see there’s an event called PageEnter

so i assume

pageLayout.PageEnter:Connect(function(page)
--sound play here
end)

This didn’t work. Unless what I tried was wrong I’m not sure this is the right event.

local pageLayout = script.Parent
pageLayout.PageEnter:Connect(function(page)
	workspace.Sound:Play()
end)

try printing something and seeing if it even prints

print("entered")

(open the output to see prints)

Nothing in the output other than what normally is there after adding a print inside the function

I’ve never used UIPageLayout either, but reading the API, I see an event named Stopped, which is called when the ‘animation’ is finished, you can use it

local pageLayout = script.Parent
pageLayout.Stopped:Connect(function()
  workspace.Sound:Play()
end)

You can also use the .Changed event

local pageLayout = script.Parent
pageLayout.Changed:Connect(function()
   workspace.Sound:Play()
end)

These both work well but a new problem is that when loading into the game it plays the sound once because it’s counting it as stopped or changed even when the gui hasn’t even been enabled yet

I was able to solve that with a simple wait. The .Changed event seems to work best for my application because it plays on every scroll instead of when it finishes scrolling on .Stopped

1 Like