Interval GUI Pop-Up

Greetings, I recently made a GUI for a pop-up, but I don’t know how to script it. Basically, the GUI will pop up every 8 minutes in the center. The user has the choice of closing the GUI and another GUI will reopen after 8 minutes. (If that makes sense)

How could I make it work? And yes, I did look over the forums and the internet to no avail.

Simply, you use wait(8*60) to wait 8 minutes. After the wait is completed, add code to show the GUI. In the close button of the GUI, it will initiate the wait code for the new pop-up.

1 Like

I understand the wait(480), but I don’t really understand how I can create a script to open a different GUI 8 minutes after closing it.

Depends on what you want it to be, do you want the GUI to appear in a random pattern indefinitely, or after the other GUI appear nothing just happens?

I would assume it’s the second idea.

You should do this in a local script, which is awesome, no remote event involved!

You get the local player first

local Players = game:GetService("Players")
local player = Players.LocalPlayer

Now we can access PlayerGui!
Then we acquire the two Gui popups of yours! I recommend storing them in replicated storage as two separate ScreenGuis.

local PopUp1 = game.ReplicatedStorage.Popuphere
local PopUp2 = game.ReplicatedStorage.Popupheretoo
--just create a path to the popups

Now here’s the part where you put the Gui on the Player’s screen.
Create a local function

local function Appear(popup)
task.wait(480) --more awesome wait()
local clone = popup:Clone()
clone.Parent = player.PlayerGui
end

popup isn’t an actual object yet, but we can assign it by simply running the function!

Appear(PopUp1)

Now the “popup” object is the PopUp1 GUI!

Great now we made the FIRST pop up appear, what about the second one?
Well since it is a popup, I assume you already have a X button to close it. So you just create a path to it.

local debounce = false
local function Appear(popup)
task.wait(480) --more awesome wait()
local clone = popup:Clone()
clone.Parent = player.PlayerGui

local closebutton = popup:FindFirstChild("CloseButton") --name both the close buttons this
closebutton.Activated:Connect(function()
popup:Destroy() --destroy the current popup
if debounce == false then -- debounce so it doesn't appear again
debounce = true
Appear(PopUp2) --Run the function again, now with popup being PopUp2
end
end)
end

Add these into your script, since it’s a local script, the event should run just fine.
May not be very optimized but I hope this help!

local Players = game:GetService("Players")
local player = Players.LocalPlayer

local PopUp1 = game.ReplicatedStorage.Popuphere
local PopUp2 = game.ReplicatedStorage.Popupheretoo
--just create a path to the popups

local debounce = false
local function Appear(popup)
task.wait(480) --more awesome wait()
local clone = popup:Clone()
clone.Parent = player.PlayerGui

local closebutton = popup:FindFirstChild("CloseButton") --name both the close buttons this
closebutton.Activated:Connect(function()
popup:Destroy() --destroy the current popup
if debounce == false then -- debounce so it doesn't appear again
debounce = true
Appear(PopUp2) --Run the function again, now with popup being PopUp2
end
end)
end

Appear(PopUp1)
1 Like

Sorry for the late reply, but yes, the first idea. So, it will appear once 8 minutes with a random GUI indefinitely.

Edit: So here’s the progress I made, but I don’t really know how I can loop this?

local Players = game:GetService("Players")
local player = Players.LocalPlayer

local PopUp = game.ReplicatedStorage.PopUpGUI:GetChildren()
--just create a path to the popups

local debounce = false
local randomNumber1 = PopUp[math.random(1, 3)]

local function Appear(popup)
	task.wait(1) --more awesome wait()
	local clone = popup:Clone()
	clone.Parent = player.PlayerGui
	
	local closebutton = clone.Frame.CloseButton--name both the close buttons this
	closebutton.Activated:Connect(function()
		local randomNumber1 = PopUp[math.random(1, 3)]
		clone:Destroy() --destroy the current popup
		if debounce == false then -- debounce so it doesn't appear again
			debounce = true
			Appear(randomNumber1) --Run the function again, now with popup being PopUp2
		end
	end)
end

Appear(randomNumber1)
1 Like

Oh yeah a bit of a mistake you made, but it should be:

	closebutton.Activated:Connect(function()
		clone:Destroy() --destroy the current popup
		if debounce == false then -- debounce so it doesn't appear again
			debounce = true
			Appear(PopUp2) --Run the function again, now with popup being PopUp2
		end
	end)
1 Like

It will loop for ur calling the same function again.

I don’t know much about scripting, but it doesn’t…

local function Appear(popup)
    if debounce then debounce = false end
	task.wait(1) --more awesome wait()
	local clone = popup:Clone()
	clone.Parent = player.PlayerGui
	
	local closebutton = clone.Frame.CloseButton--name both the close buttons this
	closebutton.Activated:Connect(function()
		local randomNumber1 = PopUp[math.random(1, 3)]
		clone:Destroy() --destroy the current popup
		if debounce == false then -- debounce so it doesn't appear again
			debounce = true
			Appear(randomNumber1) --Run the function again, now with popup being PopUp2
		end
	end)
end

It was due to the debounce. Tell me if its patched up now.

3 Likes

Sadly not. Now, the GUI doesn’t even appear. (before, it used to)

I had edited the script, so u mite need to run it again.

Yep, it works now! Thanks for the help.

1 Like