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

How to remove GUI after a long period of time?

Asked by 5 years ago

(Not removing the GUI by clicking on it)

I'm a programmer who usually scripts in Python, and I'm trying to teach myself how to script Lua so that I can start work on making ROBLOX games. I've been fiddling around with GUI's and I put this in.

wait (20)

game.startergui.ScreenGui:Remove()

I've also done a few variations of that code and things similar, and yet it still does not work too good. Anyone know what I may be doing wrong?

0
Change :Remove with :Destroy Dark_SugarX 0 — 5y
0
game.startergui.ScreenGui:Destroy() Dark_SugarX 0 — 5y
0
Edited AltNature 169 — 5y
0
time = 50 XitDev 0 — 5y

2 answers

Log in to vote
0
Answered by
AltNature 169
5 years ago
Edited 5 years ago

Change Remove() to Destroy(), a few helpful things ; You can also use PlayerGui and set variables with local

for example if the script was a LocalScript inserted in StarterPlayer.StarterPlayerScripts

local plr = game.Players.LocalPlayer
local gui = plr.PlayerGui:WaitForChild("ScreenGui")

function removegui()
 gui:Remove()
 end
 wait(20) 
 removegui()

in the example shown above, we name a function and put inside it what we want to do when we call it. then , we end the function and after ending it, as you said you wanted to wait x seconds then remove the gui. This script does exactly so!

0
Thank you, this helps a lot. It works good! allenthelegend2 2 — 5y
Ad
Log in to vote
0
Answered by
XitDev 0
5 years ago

Time = 10

wait(Time) game.Players.LocalPlayer.PlayerGui.ScreenGui:Destroy()

Answer this question