Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
1

How to stop the 'Introduction to the Game' GUI to stop reopening itself upon reset?

Asked by
RAYAN1565 691 Moderation Voter
9 years ago

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

2 answers

Log in to vote
0
Answered by
Nymint 85
9 years ago

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)
1
Does this have to be a localscript? RAYAN1565 691 — 9y
0
Unfortunately, you can't use "Players" Service inside a localscript, but you can still make a BoolValue inside the player to clone the Gui ONLY when that BoolValue is false, and then set it to true, and it will never be cloned again, ever, unless you set it to false again. Nymint 85 — 9y
0
Advice, when I'm talking about storing the BoolValue in the "Player", is by storing it in the true PLAYER and not the Player's CHARACTER, How to do this? Localscript: local player = Game:GetService("Players").LocalPlayer local bool=Instance.new("BoolValue",player) Nymint 85 — 9y
0
What 6Pen said should work, though you CAN use the Players service in LocalScripts simply by using "game.Players," there is no need to actually get the service. SlickPwner 534 — 9y
View all comments (2 more)
1
I am confused RAYAN1565 691 — 9y
1
I found a way to fix this. I put a script in the workspace and i put the screengui in the script. I simply wrote: "local ScreenGui = script.ScreenGui:Clone() game.Players.PlayerAdded:connect(function(player) player.CharacterAdded:wait() ScreenGui:Clone().Parent = player.PlayerGui end) RAYAN1565 691 — 9y
Ad
Log in to vote
0
Answered by 9 years ago

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.

Answer this question