Making an animated slideshow

I am making a slideshow that when you click an arrow, it will change.

I have a script that does that, but I want it to be animated. If anyone could tweak this script and tell me how to animate it that would be very appreciated!

local mainFrame = script.Parent.Parent
local slidesFolder = mainFrame.Slides

local backArrow = mainFrame.BackArrow
local forwardArrow = mainFrame.ForwardArrow

local currentSlide = 1
local collectedSlides = slidesFolder:GetChildren()

forwardArrow.MouseButton1Click:Connect(function()
	if currentSlide == 10 then
		print("Maximum slide alread reached!")
		return
	end
	
	currentSlide = currentSlide + 1
	for _, slide in pairs(collectedSlides) do
		if slide.Name == "Slide" .. currentSlide then
			slide.ImageTransparency = 0
		else
			slide.ImageTransparency = 1
		end
	end
end)

backArrow.MouseButton1Click:Connect(function()
	if currentSlide == 1 then
		print("Lowest slide alread reached!")
		return
	end

	currentSlide = currentSlide - 1
	for _, slide in pairs(collectedSlides) do
		if slide.Name == "Slide" .. currentSlide then
			slide.ImageTransparency = 0
		else
			slide.ImageTransparency = 1
		end
	end
end)
1 Like

You mean, animate the transparency?

I mean like when you click the forward button the slide goes to the right by animated. I thought about TweenPosition but idk if that would work.

The current slide should be at UDim2.new(0, 0, 0, 0), the next slide should be at UDim2.new(1, 0, 0, 0) and the previous slide should be at UDim2.new(-1, 0, 0, 0).

Now you just have to use TweenPosition.

I thought about that, I will do it.

1 Like

I just made a test slideshow, maybe it helps:

Slideshow.rbxm (8,3,KB)

That actually really helps! Thank you!

1 Like