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")
In the output, it did not pass the second print checkpoint, although the second slide did display.