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 9 years ago

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

Log in to vote
0
Answered by 9 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;

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!

0
Where do you put the script? adspace44 20 — 9y
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 — 9y
0
OK thx! adspace44 20 — 9y
0
No problem. :) TheeDeathCaster 2368 — 9y
Ad
Log in to vote
-1
Answered by 9 years ago

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

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

0
How do you do that? adspace44 20 — 9y
0
Like that CaptainRuno 40 — 9y
Log in to vote
-1
Answered by
Hybric 271 Moderation Voter
9 years ago

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)

Answer this question