local part = workspace.TeleportPart
local plr = game.Players.LocalPlayer
local textlabel = script.Parent.TextLabel
local x = 5
script.Parent.MouseButton1Click:Connect(function()
local humanoidrootpart = plr.Character:FindFirstChild(“HumanoidRootPart”)
if humanoidrootpart then
humanoidrootpart.CFrame = CFrame.new(part.CFrame.p) + Vector3.new(0,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
break
end
end
end
end)
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.
-- 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
end
-- continues when start = end
db = true
print("Done")
local timeleft = 5 --seconds
while timeleft > 0 do
timeleft -= task.wait(1)
textLabel.Text = "Please wait "..math.round(timeleft).." seconds..."
end
--the timer is done!
pop-up part:
local newPopup --replace with your new gui
local oldPopup --replace with your old gui
oldPopup:TweenPosition(Udim2.new(1, 0, 1, 0), Enum.EasingDirection.Out, Enum.EasingStyle.Back, 1)
newPopup:TweenPosition(oldPopup.Position, Enum.EasingDirection.Out, Enum.EasingStyle.Back, 1)
task.wait(1)
oldPopup:Destroy()
You can add these to your current code respectively.
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 could do this
‘’‘Lua
Local Debounce = true
Button.Activated:Connect(function()
If Debounce == True then
–teleport the player
Wait(5)
Else
–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
task.wait(1)
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.
end
end
end)
end
local function TweenText(Text, TimeLeft)
Text.Text = "Please wait "..tostring(TimeLeft).." seconds..."
local Info = TweenInfo.new(1, 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)
Tween:Play()
Tween.Completed:Connect(function()
task.wait(0.5) -- Adding "TweenInfo.new(1)" with task.wait(4) = 5. Which means a five second wait. Remove this line if you want.
Countdown(5) -- Starts the countdown function.
end)
end
script.Parent.MouseButton1Click:Connect(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.
end
local Info = TweenService
local RootPart = Client.Character:FindFirstChild("HumanoidRootPart")
if RootPart then
RootPart.CFrame = CFrame.new(TeleportPoint.CFrame.Position + Vector3.new(0, 5, 0))
TweenText(TextLabel)
end
end
end)
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"
task.wait(1)
if i == 5 then
textlabel.Visible = false
end
end
db = false
end