Cooldown with text Popup (Please wait 5 seconds...)

Oh I thought you wanted it to countdown in negative digits. Then replace the loop with:

local x = 5
while x <= 5 do
    wait(1) -- oops forgot to add a wait
    [GUI].Text = "Cooldown ("..tostring(x)..")"
    x = x - 1

[GUI].Visible = false 

I might have made a mistake in the original code. Sorry!


Put it before the wait 5 and take it out after the wait 5

1 Like
local part = workspace.TeleportPart
local plr = game.Players.LocalPlayer

local textlabel = script.Parent.TextLabel
local x = 5

local humanoidrootpart = plr.Character:FindFirstChild(“HumanoidRootPart”)
if humanoidrootpart then
humanoidrootpart.CFrame = +,5,0)
local x = 5
while true do
    wait(1) -- oops forgot to add a wait
    textlabel.Text = "Cooldown ("..tostring(x)..")"
    x = x - 1
if x <= 0 then 
textlabel.Visible = false

this should break the loop and set the textlabel’s visible to false once it hits 0, and of course add a debounce to the mousebutton1click because they could activate it again if the cooldown is on.

It would be more efficient to use <= like:

Why not use a for loop?

-- db = Debounce (start with: local db = true)
if db == false then return end
db = false
--start 5,end 0,count -1
for i = 5,0,-1 do -- i = current number
     textlabel.Text = "Please Wait " .. i  .. " seconds..." -- "Text" .. number .. "Text"
     task.wait(1) -- speed of the count
-- continues when start = end
db = true
1 Like

Everyone here did this incorrectly lol.

Here’s a precise cooldown:

local timeleft = 5 --seconds
while timeleft > 0 do
timeleft -= task.wait(1)
textLabel.Text = "Please wait "..math.round(timeleft).." seconds..."
--the timer is done!

pop-up part:

local newPopup --replace with your new gui
local oldPopup --replace with your old gui
oldPopup:TweenPosition(, 0, 1, 0), Enum.EasingDirection.Out, Enum.EasingStyle.Back, 1)
newPopup:TweenPosition(oldPopup.Position, Enum.EasingDirection.Out, Enum.EasingStyle.Back, 1)

You can add these to your current code respectively.

Yeah you are kind of right because I tried all of those and it made not alot of sense.
I am going to try this right now!

I did it and this happened, its showing an error:

You didn’t specify them in your code yourself.

Yeah sorry I kind of did not understood how oldpopup and newpopup thing is going to work

1 Like

It’s the location of the new pop up. But it kind of sounds like your code didn’t make one.

1 Like

Hmm so what should I do? I am still a bit confused with that part. Will try without tween till you reply

1 Like

I’m confused as well. What is the pop up for your GUI?

1 Like

lets forget about tween part for now and can you help me with detecting 2 clicks?
like I want that pop up to happen after the user clicks the button more than once.

You can use Button.Activated (for your button) and the parameter tells us how many clicks it has:

if clicks < 2 then

You could do this
Local Debounce = true
If Debounce == True then
–teleport the player
–open the wait 5 seconts thingy

Hi there. You can copy and paste this and adjust it however you need to do so!

local Players = game:GetService("Players")
local TweenService = game:GetService("TweenService")
local RunService = game:GetService("RunService")
local TeleportPoint = workspace.TeleportPart
local Client = Players.LocalPlayer
local Active = false
local ShouldCountDown = false
local TextLabel = script.Parent -- Change this to whatever you need.
local RunFunction

function Countdown(Time, Text)
	RunFunction = RunService.Heartbeat:Connect(function(DT)
		if ShouldCountDown == false then
			ShouldCountDown = true
			Time -= 1
			ShouldCountDown = false
			if Time <= 0 then -- If there are any bugs that caused the countdown to go past 0 which means it'd be -1, then the code will stop instead of being permanently stopped because it hit -1.
				Active = false
				Text.TextTransparency = 1
				Text.TextStrokeTransparency = 1
				--	Text.BackgroundTransparency = 1 -- Remove the dashes that come before "Text.BackgroundTransparency" to make this transparent too.
				RunFunction:Disconnect() -- Disconnects the event so it will not continue running in the background.

local function TweenText(Text, TimeLeft)
	Text.Text = "Please wait "..tostring(TimeLeft).." seconds..."
	local Info =, Enum.EasingStyle.Linear, Enum.EasingDirection.In, 0, false) -- Change false to true if you'd like it to go away right after appearing.
	local Goal = {}
	Goal.TextTransparency = 0
	Goal.TextStrokeTransparency = 0
	--	Goal.BackgroundTransparency = 0 -- Remove the dashes that come before "Goal.BackgroundTransparency" to apply this to the goal.
	local Tween = TweenService:Create(Text, Info, Goal)
		task.wait(0.5) -- Adding "" with task.wait(4) = 5. Which means a five second wait. Remove this line if you want.
		Countdown(5) -- Starts the countdown function.

	if Active == false then
		Active = true
		if not game.Workspace:FindFirstChild(Client.Name) then
			return -- Stops the code from proceeding if the player's character does not exist.
		local Info = TweenService
		local RootPart = Client.Character:FindFirstChild("HumanoidRootPart")
		if RootPart then
			RootPart.CFrame = +, 5, 0))
1 Like

Alright replace this with: – Trainmaster2341 had it right
– put a local on top (out of function)
local db = false

if db == false then
db = true
textlabel.Visible = true
for i = 5,0,-1 do
	textlabel.Text = "Please wait "..i.." seconds"
	if i == 5 then
		textlabel.Visible = false
db = false

Mate this is insane script, not just you helped me but I got to learn alot of things as well. Thank you so much mate :))

And yeah theres a new post.
I really need help with Player Gui saving script > Save Gui (Button Color) & (Image)

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.