Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

How do you make a GUI appear only once?

This is what I have used so for;

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

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

3 answers

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;

local Time = 5 --This is the amount of time before the Gui is removed
local GuiName = "ScreenGui" --This is where the Name of the Gui will be [You can change this to the name of your Gui]
local 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'
if 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'
repeat wait() until plr:FindFirstChild("PlayerGui") --I like to use the 'repeat until nil' loop to wait until it finds/gets all the requirements
local Gui = game.Lighting:FindFirstChild(GuiName):Clone() --This defines the Gui, and Clones it
Gui.Parent = plr.PlayerGui --Sets the Gui's Parent to the Player's PlayerGui; PlayerGui/Screen
wait(Time) --This is the amount of time before the Gui is removed
Gui:Destroy() --This will destroy the Gui
end --This ends the 'if' code statement
end --This ends the 'function' code statement

game.Players.PlayerAdded:connect(PlayerSpawn) --Now, when a Player joins, it will fire the event/function

Hope this helped!

4 comments

0

Where do you put the script?

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.

0

OK thx!

0

No problem. :)

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

Game.Players.PlayerAdded:connect(function(player)
--Show & remove GUI
end)

2 comments

0

How do you do that?

0

Like that

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

game.Players.PlayerAdded:connect(function(player)
local HowLongYouWantTheGuiToRemove = 10 -- time to remove gui
local x = game.Lighting.BRUH:Clone()
x.Parent = player.PlayerGui
wait(HowLongYouWantTheGuiToRemove)
x:remove()
end)

This discussion is preserved as it was. New answers, comments, and votes are closed.