Hello, I am making a slideshow for my hotel for trainings. I want it so the welcome screen changes from 2 different messages and fades... I got that to work. The issue is, if I want to go to the next page(So we can start the slideshow), it continues the loop from the welcome screen. I do not want that. If the page is 1, I want the loop to stop. Here is my code: NOTE I DO NOT LIKE USING VARIABLES!!! And the code cut off, hit the button when mouse is over the code to see the "full" code.
loop = false function onClicked(playerWhoClicked) --On Welcome-- if script.Parent.Page.Value == 0 then --If Only welcome page = false(Meaning not on welcome page) then do...-- print(2) script.Parent.Display.Decal.Texture = "rbxassetid://109582196" print(3) script.Parent.Display.SurfaceGui.TextLabel.Text = "Welcome to training! This is the Reception Training. Please STS." wait(5) loop = true --END OF CHANGING-- if loop == true then --START OF TEXT CHANGING-- script.Parent.Display.SurfaceGui.TextLabel.TextTransparency = .1 wait(.15) script.Parent.Display.SurfaceGui.TextLabel.TextTransparency = .2 wait(.15) script.Parent.Display.SurfaceGui.TextLabel.TextTransparency = .3 wait(.15) script.Parent.Display.SurfaceGui.TextLabel.TextTransparency = .4 wait(.15) script.Parent.Display.SurfaceGui.TextLabel.TextTransparency = .5 wait(.15) script.Parent.Display.SurfaceGui.TextLabel.TextTransparency = .6 wait(.15) script.Parent.Display.SurfaceGui.TextLabel.TextTransparency = .7 wait(.15) script.Parent.Display.SurfaceGui.TextLabel.TextTransparency = .8 wait(.15) script.Parent.Display.SurfaceGui.TextLabel.TextTransparency = .9 wait(.15) script.Parent.Display.SurfaceGui.TextLabel.TextTransparency = 1 wait(.15) --END OF TEXT FADING-- --START OF NEW WELCOME TEXT-- script.Parent.Display.SurfaceGui.TextLabel.Text = "Please enjoy a cup of coffee and talk a while! We will begin soon." script.Parent.Display.SurfaceGui.TextLabel.TextTransparency = .9 wait(.15) script.Parent.Display.SurfaceGui.TextLabel.TextTransparency = .8 wait(.15) script.Parent.Display.SurfaceGui.TextLabel.TextTransparency = .7 wait(.15) script.Parent.Display.SurfaceGui.TextLabel.TextTransparency = .6 wait(.15) script.Parent.Display.SurfaceGui.TextLabel.TextTransparency = .5 wait(.15) script.Parent.Display.SurfaceGui.TextLabel.TextTransparency = .4 wait(.15) script.Parent.Display.SurfaceGui.TextLabel.TextTransparency = .3 wait(.15) script.Parent.Display.SurfaceGui.TextLabel.TextTransparency = .2 wait(.15) script.Parent.Display.SurfaceGui.TextLabel.TextTransparency = .1 wait(.15) script.Parent.Display.SurfaceGui.TextLabel.TextTransparency = 0 wait(5) script.Parent.Display.SurfaceGui.TextLabel.TextTransparency = .1 wait(.15) script.Parent.Display.SurfaceGui.TextLabel.TextTransparency = .2 wait(.15) script.Parent.Display.SurfaceGui.TextLabel.TextTransparency = .3 wait(.15) script.Parent.Display.SurfaceGui.TextLabel.TextTransparency = .4 wait(.15) script.Parent.Display.SurfaceGui.TextLabel.TextTransparency = .6 wait(.15) script.Parent.Display.SurfaceGui.TextLabel.TextTransparency = .7 wait(.15) script.Parent.Display.SurfaceGui.TextLabel.TextTransparency = .8 wait(.15) script.Parent.Display.SurfaceGui.TextLabel.TextTransparency = .9 wait(.15) script.Parent.Display.SurfaceGui.TextLabel.TextTransparency = 1 --END OF NEW TEXT-- --START OF FADING-- script.Parent.Display.SurfaceGui.TextLabel.Text = "Welcome to training! This is the Reception Training. Please STS." script.Parent.Display.SurfaceGui.TextLabel.TextTransparency = .9 wait(.15) script.Parent.Display.SurfaceGui.TextLabel.TextTransparency = .8 wait(.15) script.Parent.Display.SurfaceGui.TextLabel.TextTransparency = .7 wait(.15) script.Parent.Display.SurfaceGui.TextLabel.TextTransparency = .6 wait(.15) script.Parent.Display.SurfaceGui.TextLabel.TextTransparency = .5 wait(.15) script.Parent.Display.SurfaceGui.TextLabel.TextTransparency = .4 wait(.15) script.Parent.Display.SurfaceGui.TextLabel.TextTransparency = .3 wait(.15) script.Parent.Display.SurfaceGui.TextLabel.TextTransparency = .2 wait(.15) script.Parent.Display.SurfaceGui.TextLabel.TextTransparency = .1 wait(.15) script.Parent.Display.SurfaceGui.TextLabel.TextTransparency = 0 wait(5) end --END OF LOOP-- end --End of the IF Statement-- if script.Parent.Page.Value == 1 then script.Parent.Display.SurfaceGui.TextLabel.Text = "Please copy the following in your notes:" wait(5) script.Parent.Display.SurfaceGui.TextLabel.Text = "Reception - Gives rooms out to customers. Can ONLY use :give." end end --End Of the Function-- --When to call the function-- script.Parent.Part.SurfaceGui.NextButton.MouseButton1Down:connect(onClicked) script.Parent.Part.SurfaceGui.PrevButton.MouseButton1Down:connect(onClicked) script.Parent.Part.SurfaceGui.WelcomeButton.MouseButton1Down:connect(onClicked)
I don't see your while true loop but if you want a while true loop to stop when your variable "loop = false" just include a break in your loop when the variable is false. Also, you've said you don't like variables but using a variable for your numbers or maybe a for loop will definitely help you instead of pasting the lines over and over again.
while true do --Stuff if loop == false then break end wait() end