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

Ho do u make a GUI disappear after a certain time?

Asked by
alsome495 -21
7 years ago

How do make a gui disappear after 5 seconds and i don know how to script it right so how do i define it and make it disappear?

3 answers

Log in to vote
0
Answered by 7 years ago
Edited 7 years ago

GO TO THE BOTTOM FOR :DESTROY INSTRUCTIONS

You could do the simple, visible, wait, invisible thing

You Need To Put This Script In A Local Script. Also, it Needs To Be In The Frame You Want To Make Invisible.

You want it to be invisible. If you don't put in into the Frame, but put the parent as The Screen gui, it wont work because a ScreenGui wont have the property .Visible which determines if u can see the frame or not.


script.Parent.Visible = true -- Frame is visible when you load the game wait(5) -- Waits 5 seconds script.Parent.Visible = false-- Makes It Invisible.

However, If you do put the script in The Screen Gui, change the script.Parent to script.Parent.NameOfFrame.

If you don't want it to come up everytime after death, use :Destroy if you don't want it pop up ever after death. Instead of making it invisible, destroy it. So Like :script.Parent : Destroy () or something along the lines of that.

(change Name Of Frame to whatever the frame you want to make invisible is called)


FROM THIS POINT ON, ITS TO USE DESTROY

For Destroy, The whole thing will be different. now listen to the instructions carefully

1)First make a Script in Workspace. and in that script put the following:

local ui = game.ReplicatedStorage.ScreenGui  --This is the gui to be cloned (Chnage "ScreenGui" to what your Screen Gui Is Called)


game.Players.PlayerAdded:connect(function(plr) -- when a player joins...
    local plrui = plr:WaitForChild("PlayerGui"); -- finds the gui
    ui:Clone().Parent = plrui; -- puts it into the player GUI. 
end)

2) Then, You put you GUI into Replicated storage

3) Inside the Frame you want to go invisible, insert a Local Script

4) Inside The Local Script, Insert The Following:

wait(10) -- set the number to how long you want it to be on for
script.Parent:Destroy() -- using :Destroy() means it should not pop up again

THE GUI COMES UP NO MATTER WHAT TEAM YOU ARE ON. IT COMES UP WHEN PLAYER IS ADDED TO THE GAME. AND SHOULDN'T COME UP AFTER RESPAWN

If you need anymore help, please comment on my answer and I will see what I can Do. I hope this helped You :P

0
Please Press Accept Answer ( which is above or under this comment ) If This Helped. The Script Has Been Tested. If it doesn't work, then comment and I will help you debug the script or find the problem. tonyv537 95 — 7y
0
Thank you i will try it out if and if i have a question i will let you know alsome495 -21 — 7y
0
okay. Thanks tonyv537 95 — 7y
0
Thx Eman_Dabyeet 0 — 3y
Ad
Log in to vote
0
Answered by
Morficc 36
7 years ago
Edited 7 years ago

Not really sure as to the specifics of "defining" it, you are requesting. But if you already have a gui created, uncheck "Visible" in the properties. Then in the script to call the GUI window, you would simply have to:

script.Parent.GuiWindow.Visible = true
wait(5)
script.Parent.GuiWindow.Visible = false

Simple answer I know, but if you give a little more detail, I would be happy to try to expand upon it, as far as my mediocre knowledge will allow me.


Create a new GUI inside of StarterGui. (ScreenGui first, then your frame or whatever other element)

Place a localscript within the ScreenGui with the following:

wait(5)
script.Parent:Destroy()

That will open the GUI for roughly 5 seconds each time a player joins, then destroys it. If you need to reopen the same GUI at other points, you may just want to use the following:

wait(5)
script.Parent.Visible = false

and then set visible to true in a later script, when you need it again.

0
I am trying to make a Player spawn in and as soon as that happens they see the gui and then another gui will pop up then the core main gui but i just need the to guis to pop up for a set time then disappear alsome495 -21 — 7y
0
Is that good cause i really am stuck alsome495 -21 — 7y
0
edited my above answer. Morficc 36 — 7y
Log in to vote
0
Answered by 7 years ago
Edited 7 years ago

Well, if you're asking how the script will wait 5 seconds before removing the part, you'd use the Wait function; although, to note, it does work in seconds, but it bases around the time frame: say you want the Wait function to, well, wait 1 second, and when you fire it (w/ the print function), it'll return a number around 0.9990039349834 (That's what it'll look similar to when you fire it in: it varies each time it's fired, but it never waits exactly the number you want it to, only around it); it bases around the number, but it's not exact/ on-point.

If you mean destroying the asset after waiting a duration, then all you need do is use the Destroy function, which will "destroy" it, but more specifically set the parent to nil, lock it, and will add it to the Garbage Collector; you can also uses the AddItem function of the Debris Service, as it'll set the asset's parent property to nil after a specific amount of time, however, you'll need to set the parent property of the asset first, as the AddItem function does not automatically set a parent: it only sets the asset's parent property to nil after a specified amount of time.

Here's an example of this:

local brickExample = game.Workspace.Part -- Well, if you have a brick named 'Part' in the Workspace service :P ; the variable, brickExample, is set to the Part of the Workspace. (Confusing to explain e.e)

game.Debris:AddItem(brickExample, 5) -- The first argument is the asset that'll be "removed" after the specified amount of time, and the second is the, well, specified amount of time. lol
while brickExample.Parent ~= nil do wait() end -- I don't recommend you do this; this is for example & explanation purposes only; however, the reason I used this is b/c unlike the Wait function, the AddItem function doesn't wait before going on to the next line: it fires, but lets the code proceed
brickExample.Parent = game.Workspace -- Sets the parent property back to the Workspace

If you want my person opinion, I recommend using the Destroy function for when you want to, well, remove/ destroy an asset permanently, while for the AddItem function, I recommend you use it for when you want an asset to "disappear" after a specified amount of time, then be able to re-add it later on. :)

Hope this helped you in any way! :D

Answer this question