I need help making these GUIs loop

So I’ve been making this thing where you click the GUI arrow to make the next image come up but on the last image when you click it it doesn’t restart.

So I need to make it endlessly loop

here are the image arrow scripts-


as you can see it makes the image invisible

I’ve tried making it so when you click the last image arrow it makes the next one visible again but it didnt work

The last image arrow’s function should make the last frame invisible and then show the first frame again. Something like:

script.Parent.MouseButton1Down:Connect(function()
    script.Parent.Parent.Parent.Visible = false
    script.Parent.Parent.Parent.Parent.Frame20.Visible = true
end)

Then you’d be back at the first frame and it would do the same thing all over again.

(Assuming Frame20, Frame21, Frame22 are setup with an image, an arrow button image, and a local script.)

1 Like

Yes. This will work. Also, it would be a lot easier to maintain and code if the op had one button and one script with a table of the images.

1 Like

I didn’t want to over complicate it for them. So I tried to show them using what they had.

1 Like

If you would like to switch between frames, you could use UIPageLayout and invoke :Next() and :Previous()

With the arrow buttons configured, you could do something similar like this:

--// Right button
upButton.MouseButton1Down:Connect(function()
      uiPageLayout:Next()
end)

--// Left button
leftButton.MouseButton1Down:Connect(function()
      uiPageLayout:Previous()
end)

To ensure switching doesn’t have issues showing frames, make sure all the frames are visible so that they’re easy to channel.

Thanks so much bro, it worked!

2 Likes