So I have an introduction GUI that introduces the game before you actually play it. But I came across a problem. Once you reset your character or if you die in-game, the GUI opens up again.. I only want it to show once and not repeat after you reset your character or die. How do I stop that?
Here's the script that I created that plays the Introduction GUI
a = script.Parent.Frame.ImageLabel b = script.Parent.Frame.ImageLabel2 f = script.Parent.Frame.TextLabel x = script.Parent.Frame y = script.Parent.Frame.PlayButton f.Transparency = 0 x.Transparency = 0 y.Transparency = 0 a.Visible = true b.Visible = false wait(5) f.TextTransparency = 0.1 wait(0.2) f.TextTransparency = 0.2 wait (0.2) f.TextTransparency = 0.3 wait(0.2) f.TextTransparency = 0.4 wait (0.2) f.TextTransparency = 0.5 wait (0.2) f.TextTransparency = 0.6 wait(0.2) f.TextTransparency = 0.7 wait (0.2) f.TextTransparency = 0.8 wait (0.2) f.TextTransparency = 0.9 wait(0.2) f.TextTransparency = 1 f.Text = "Welcome to Abandoned Island!" f.TextTransparency = 0.9 wait(0.2) f.TextTransparency = 0.8 wait (0.2) f.TextTransparency = 0.7 wait(0.2) f.TextTransparency = 0.6 wait (0.2) f.TextTransparency = 0.5 wait (0.2) f.TextTransparency = 0.4 wait(0.2) f.TextTransparency = 0.3 wait (0.2) f.TextTransparency = 0.2 wait (0.2) f.TextTransparency = 0.1 wait(0.2) f.TextTransparency = 0 wait(5) f.TextTransparency = 0.1 wait(0.2) f.TextTransparency = 0.2 wait (0.2) f.TextTransparency = 0.3 wait(0.2) f.TextTransparency = 0.4 wait (0.2) f.TextTransparency = 0.5 wait (0.2) f.TextTransparency = 0.6 wait(0.2) f.TextTransparency = 0.7 wait (0.2) f.TextTransparency = 0.8 wait (0.2) f.TextTransparency = 0.9 wait(0.2) f.TextTransparency = 1 a.Visible = false f.Text = "Made by RAYAN1565" b.Visible = true f.TextTransparency = 0.9 wait(0.2) f.TextTransparency = 0.8 wait (0.2) f.TextTransparency = 0.7 wait(0.2) f.TextTransparency = 0.6 wait (0.2) f.TextTransparency = 0.5 wait (0.2) f.TextTransparency = 0.4 wait(0.2) f.TextTransparency = 0.3 wait (0.2) f.TextTransparency = 0.2 wait (0.2) f.TextTransparency = 0.1 wait(0.2) f.TextTransparency = 0 wait(5) f.TextTransparency = 0.1 wait(0.2) f.TextTransparency = 0.2 wait (0.2) f.TextTransparency = 0.3 wait(0.2) f.TextTransparency = 0.4 wait (0.2) f.TextTransparency = 0.5 wait (0.2) f.TextTransparency = 0.6 wait(0.2) f.TextTransparency = 0.7 wait (0.2) f.TextTransparency = 0.8 wait (0.2) f.TextTransparency = 0.9 wait(0.2) f.TextTransparency = 1 f.Text = "Brought to you by Romarenem Productions" f.TextTransparency = 0.9 wait(0.2) f.TextTransparency = 0.8 wait (0.2) f.TextTransparency = 0.7 wait(0.2) f.TextTransparency = 0.6 wait (0.2) f.TextTransparency = 0.5 wait (0.2) f.TextTransparency = 0.4 wait(0.2) f.TextTransparency = 0.3 wait (0.2) f.TextTransparency = 0.2 wait (0.2) f.TextTransparency = 0.1 wait(0.2) f.TextTransparency = 0 wait(6) f.TextTransparency = 0.1 wait(0.2) f.TextTransparency = 0.2 wait (0.2) f.TextTransparency = 0.3 wait(0.2) f.TextTransparency = 0.4 wait (0.2) f.TextTransparency = 0.5 wait (0.2) f.TextTransparency = 0.6 wait(0.2) f.TextTransparency = 0.7 wait (0.2) f.TextTransparency = 0.8 wait (0.2) f.TextTransparency = 0.9 wait(0.2) f.TextTransparency = 1 f.Text = "Thanks for playing! Hope you enjoy ^_^" f.TextTransparency = 0.9 wait(0.2) f.TextTransparency = 0.8 wait (0.2) f.TextTransparency = 0.7 wait(0.2) f.TextTransparency = 0.6 wait (0.2) f.TextTransparency = 0.5 wait (0.2) f.TextTransparency = 0.4 wait(0.2) f.TextTransparency = 0.3 wait (0.2) f.TextTransparency = 0.2 wait (0.2) f.TextTransparency = 0.1 wait(0.2) f.TextTransparency = 0 wait (5) f.TextTransparency = 0.1 wait(0.2) f.TextTransparency = 0.2 wait (0.2) f.TextTransparency = 0.3 wait(0.2) f.TextTransparency = 0.4 wait (0.2) f.TextTransparency = 0.5 wait (0.2) f.TextTransparency = 0.6 wait(0.2) f.TextTransparency = 0.7 wait (0.2) f.TextTransparency = 0.8 wait (0.2) f.TextTransparency = 0.9 wait(0.2) f.TextTransparency = 1 wait(1) x.BackgroundTransparency = 0.1 a.ImageTransparency = 0.1 b.ImageTransparency = 0.1 wait(0.2) x.BackgroundTransparency = 0.2 a.ImageTransparency = 0.2 b.ImageTransparency = 0.2 wait(0.2) x.BackgroundTransparency = 0.3 a.BackgroundTransparency = 0.3 b.BackgroundTransparency = 0.3 wait(0.2) x.BackgroundTransparency = 0.4 a.ImageTransparency = 0.4 b.ImageTransparency = 0.4 wait(0.2) x.BackgroundTransparency = 0.5 a.ImageTransparency = 0.5 b.ImageTransparency = 0.5 wait(0.2) x.BackgroundTransparency = 0.6 a.ImageTransparency = 0.6 b.ImageTransparency = 0.6 wait(0.2) x.BackgroundTransparency = 0.7 a.ImageTransparency = 0.7 b.ImageTransparency = 0.7 wait(0.2) x.BackgroundTransparency = 0.8 a.ImageTransparency = 0.8 b.ImageTransparency = 0.8 wait(0.2) x.BackgroundTransparency = 0.9 a.ImageTransparency = 0.9 b.ImageTransparency = 0.9 wait(0.2) x.BackgroundTransparency = 1 a.ImageTransparency = 1 b.ImageTransparency = 1 y.Visible = false a.Visible = false b.Visible = false y.Active = false a.Active = false b.Active = false
Woah, I suggest you to learn about Loops.
This happens due to the fact that adding any gui in StarterGui would give that gui to every player that respawned.
(You need that gui to be inside the script in order for it to work)
local Gui=script:WaitForChild("GuiName") --Locates the Gui assumed to be inside the script Game:GetService("Players").PlayerAdded:connect(function(NewPlayer) --When a player joins, do: repeat wait() until NewPlayer:FindFirstChild("PlayerGui") --Waits for the PlayerGui to prevent glitches. Gui:Clone().Parent=NewPlayer:WaitForChild("PlayerGui") --Clones inmediately to a player's screen (PlayerGui) end)
6Pen has already answered your question, but I'll help you edit your script so that you don't have so many unnecessary lines.
Your script could be so much more efficient. Here is the rewritten code, more efficient, with comments explaining everything:
a = script.Parent.Frame.ImageLabel b = script.Parent.Frame.ImageLabel2 f = script.Parent.Frame.TextLabel x = script.Parent.Frame y = script.Parent.Frame.PlayButton f.Transparency = 0 x.Transparency = 0 y.Transparency = 0 a.Visible = true b.Visible = false wait(5) repeat --Basically, this repeats "wait(0.2)" and the Transparency ticker until the Transparency is equal to 0. wait(0.2) f.TextTransparency = f.TextTransparency - 0.1 until f.TextTransparency == 0 end --I can't remember if repeats use ends, I think they do. If not then remove this, and the one below. f.Text = "Welcome to Abandoned Island!" wait(5) repeat wait(0.2) f.TextTransparency = f.TextTransparency + 0.1 until f.TextTransparency == 1
Just use repeat like I did to replace all those long lines of code. It will also help prevent so many typos, which are almost impossible to avoid with all of those lines of code.