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

How to remove GUI after a long period of time?

(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?

4 comments

0

Change :Remove with :Destroy

0

game.startergui.ScreenGui:Destroy()

0

Edited

0

time = 50

2 answers

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!

1 comment

0

Thank you, this helps a lot. It works good!

Time = 10

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

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