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

How do you make a GUI appear only once?

Asked by 10 years ago

This is what I have used so for;

1Game.Players.PlayerAdded:connect(function(player)
2player.CharacterAdded:wait()
3--Show & remove GUI
4end)

I don't know where to insert it and, I have tried using it and it doesn't work.

3 answers

Log in to vote
0
Answered by 10 years ago

As CaptainRuno and Hrbric have posted, why not use the .PlayerAdded event? The .PlayerAdded will only fire once, it won't refire again when the Player dies. Heres how you'd do it;

01local Time = 5 --This is the amount of time before the Gui is removed
02local GuiName = "ScreenGui" --This is where the Name of the Gui will be [You can change this to the name of your Gui]
03local function PlayerSpawn(plr) --This is our function; when the player joins, this function will be fired; the player that has joined will be defined as 'plr'
04if game:GetService("Lighting") and game.Lighting:FindFirstChild(GuiName) then --You don't have to use '.Lighting', you could use another Service like 'ReplicatedStorage', this will check to see if the script gets the service of '.Lighting', and finds the Gui within '.Lighting'
05repeat wait() until plr:FindFirstChild("PlayerGui") --I like to use the 'repeat until nil' loop to wait until it finds/gets all the requirements
06local Gui = game.Lighting:FindFirstChild(GuiName):Clone() --This defines the Gui, and Clones it
07Gui.Parent = plr.PlayerGui --Sets the Gui's Parent to the Player's PlayerGui; PlayerGui/Screen
08wait(Time) --This is the amount of time before the Gui is removed
09Gui:Destroy() --This will destroy the Gui
10end --This ends the 'if' code statement
11end --This ends the 'function' code statement
12 
13game.Players.PlayerAdded:connect(PlayerSpawn) --Now, when a Player joins, it will fire the event/function

Hope this helped!

0
Where do you put the script? adspace44 20 — 10y
0
You can put the Script into the Workspace, or into ServerScriptService, I recommend ServerScriptService, and the script can/has to be a 'Script' object. TheeDeathCaster 2368 — 10y
0
OK thx! adspace44 20 — 10y
0
No problem. :) TheeDeathCaster 2368 — 10y
Ad
Log in to vote
-1
Answered by 10 years ago

Remove the character added, that fires when the character resets or spawns again.

1Game.Players.PlayerAdded:connect(function(player)
2--Show & remove GUI
3end)
0
How do you do that? adspace44 20 — 10y
0
Like that CaptainRuno 40 — 10y
Log in to vote
-1
Answered by
Hybric 271 Moderation Voter
10 years ago

Instructions: 1. Make the GUI named, "BRUH" **
**2. Put it in Lighting

1game.Players.PlayerAdded:connect(function(player)
2local HowLongYouWantTheGuiToRemove = 10 -- time to remove gui
3local x = game.Lighting.BRUH:Clone()
4x.Parent = player.PlayerGui
5wait(HowLongYouWantTheGuiToRemove)
6x:remove()
7end)

Answer this question