Game Intro Slideshow Bug

I am trying to create a slideshow of three ImageLabels as an intro to my game.
However, my script will always stop before moving on to the third slide. I have tried to alternate in between breaking the loop with BackgroundTransparency and ImageTransparency, all it did was change the moment where it blocked and made the transition less smooth when the breaking point was set to ImageTransparency.
Note: I attempted to make the transitions smooth.
Here is my code:

-- Variables
local firstSlide = game.Players.LocalPlayer:WaitForChild("PlayerGui"):WaitForChild("Slides"):WaitForChild("FirstSlide")
local secondSlide = game.Players.LocalPlayer:WaitForChild("PlayerGui"):WaitForChild("Slides"):WaitForChild("SecondSlide")
local thirdSlide = game.Players.LocalPlayer:WaitForChild("PlayerGui"):WaitForChild("Slides"):WaitForChild("ThirdSlide")

firstSlide.BackgroundColor3 = Color3.fromRGB(0, 0, 0)
secondSlide.BackgroundColor3 = Color3.fromRGB(0, 0, 0)
thirdSlide.BackgroundColor3 = Color3.fromRGB(0, 0, 0)

-- Script
firstSlide.Visible = true
secondSlide.Visible = true
secondSlide.ImageTransparency = 1
secondSlide.BackgroundTransparency = 1
thirdSlide.Visible = true
thirdSlide.ImageTransparency = 1
thirdSlide.BackgroundTransparency = 1
wait(5)
print("1")

while true do
	firstSlide.ImageTransparency = firstSlide.ImageTransparency + 0.01
	firstSlide.BackgroundTransparency = firstSlide.BackgroundTransparency + 0.01
	wait()
	secondSlide.ImageTransparency = secondSlide.ImageTransparency - 0.01
	secondSlide.BackgroundTransparency = secondSlide.BackgroundTransparency - 0.02
	if secondSlide.BackgroundTransparency == 0 then
		break
	end
end
firstSlide.Visible = false
print("2")

wait(5)
while true do
	secondSlide.ImageTransparency = secondSlide.ImageTransparency + 0.01
	secondSlide.BackgroundTransparency = secondSlide.BackgroundTransparency + 0.01
	wait()
	thirdSlide.ImageTransparency = thirdSlide.ImageTransparency - 0.01
	thirdSlide.BackgroundTransparency = thirdSlide.BackgroundTransparency - 0.02
	if thirdSlide.BackgroundTransparency == 0 then
		break
	end
end
secondSlide.Visible = false

print("3")

wait(5)
while true do
	thirdSlide.ImageTransparency = thirdSlide.ImageTransparency + 0.01
	thirdSlide.BackgroundTransparency = thirdSlide.BackgroundTransparency + 0.01
	wait()
	if thirdSlide.BackgroundTransparency == 1 then
		break
	end
end
thirdSlide.Visible = false

print("4")

image

In the output, it did not pass the second print checkpoint, although the second slide did display.

1 Like

You should probably use TweenService instead of loops to change values like transparency.

TweenService will make your animations smooth and do not require of a loop.
I guess you don’t know anything about this so let me make some code for you:

local TweenService = game:GetService("TweenService")
local player = game:GetService("Players").LocalPlayer
local firstSlide = player:WaitForChild("PlayerGui"):WaitForChild("Slides"):WaitForChild("FirstSlide")
local secondSlide = player:WaitForChild("PlayerGui"):WaitForChild("Slides"):WaitForChild("SecondSlide")
local thirdSlide = player:WaitForChild("PlayerGui"):WaitForChild("Slides"):WaitForChild("ThirdSlide")

firstSlide.BackgroundColor3 = Color3.fromRGB(0, 0, 0)
secondSlide.BackgroundColor3 = Color3.fromRGB(0, 0, 0)
thirdSlide.BackgroundColor3 = Color3.fromRGB(0, 0, 0)

-- Script
firstSlide.Visible = true
secondSlide.Visible = true
secondSlide.ImageTransparency = 1
secondSlide.BackgroundTransparency = 1
thirdSlide.Visible = true
thirdSlide.ImageTransparency = 1
thirdSlide.BackgroundTransparency = 1
wait(5)
print("1")

local TweenInformation = TweenInfo.new(1, Enum.EasingStyle.Linear)

TweenService:Create(firstSlide, TweenInformation, { ImageTransparency = 1 }):Play()
TweenService:Create(firstSlide, TweenInformation, { BackgroundTransparency = 1 }):Play()
TweenService:Create(secondSlide, TweenInformation, { ImageTransparency = 0 }):Play()
TweenService:Create(secondSlide, TweenInformation, { BackgroundTransparency = 0 }):Play()

firstSlide.Visible = false
print("2")

wait(5)
TweenService:Create(secondSlide, TweenInformation, { ImageTransparency = 1 }):Play()
TweenService:Create(secondSlide, TweenInformation, { BackgroundTransparency = 1 }):Play()
TweenService:Create(thirdSlide, TweenInformation, { ImageTransparency = 0 }):Play()
TweenService:Create(thirdSlide, TweenInformation, { BackgroundTransparency = 0 }):Play()
secondSlide.Visible = false

print("3")

wait(5)
TweenService:Create(thirdSlide, TweenInformation, { ImageTransparency = 1 }):Play()
TweenService:Create(thirdSlide, TweenInformation, { BackgroundTransparency = 1 }):Play()
thirdSlide.Visible = false

print("4")

I have replaced all your loops for TweenService animations which run smoother and should work just fine.

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.