Problem with click delay

You can write your topic however you want, but you need to answer these questions:

  1. What do you want to achieve? Keep it simple and clear!
    So i wanna do click delay for generator button
  2. What is the issue? Include screenshots / videos if possible!
    issue is - when i click button, button text become time which player need to wait, but when i click the button, my delay is 2 seconds, text just stop on 1.9 and don’t go lower each 0.1s. here is screenshot: image
  3. What solutions have you tried so far? Did you look for solutions on the Developer Hub?
    I tryed to make debug thing, but that didn’t help

My code:

local PlayerService = game:GetService("Players")
local Player = PlayerService.LocalPlayer
local GuiService = Player.PlayerGui
local GameGUI = GuiService.GameGUI
local RNGBar = GameGUI.GameFrame.PlayableFrame.RNGBar
local RNGProgress = RNGBar.RNGP
local RNGBarFiller = RNGBar.Filler
local RNGClicker = script.Parent
local RNGMultiValue = script.Parent.RNGMulti
local RNGNumber = 0
local ClickWait = 0
local DB = 2
RNGClicker.MouseButton1Click:Connect(function()
	RNGNumber = math.random(1,10)
	RNGProgress.Text = RNGNumber
	ClickWait = 2
	while wait() do
		DB = DB - 0.1
		RNGClicker.Text = ClickWait - 0.1
		wait(0.1)
	end
end)
1 Like

Sorry for bumping, just still can’t solve

Hello?? Can someone help me???

Oh lol i figured out error am just stupid

Okay nevermind, i didn’t. It’s don’t work

update ClickWait during the while loop.
it never gets changed in the loop, so the number displayed remains the same

just do a

ClickWait = ClickWait - 0.1
RNGClicker.Text = ClickWait

I think you should’ve add while wait() do out of MouseButton1Click

Only because i think what the loop repeats with Click, make a thing like this:

local PlayerService = game:GetService("Players")
local Player = PlayerService.LocalPlayer
local GuiService = Player.PlayerGui
local GameGUI = GuiService.GameGUI
local RNGBar = GameGUI.GameFrame.PlayableFrame.RNGBar
local RNGProgress = RNGBar.RNGP
local RNGBarFiller = RNGBar.Filler
local RNGClicker = script.Parent
local RNGMultiValue = script.Parent.RNGMulti
local RNGNumber = 0
local ClickWait = 0
local DB = 2
RNGClicker.MouseButton1Click:Connect(function()
	RNGNumber = math.random(1,10)
	RNGProgress.Text = RNGNumber
	ClickWait = 2
end)

while wait(0.1) do
	DB = DB - 0.1
	RNGClicker.Text = ClickWait - 0.1
end
1 Like
local PlayerService = game:GetService("Players")
local Player = PlayerService.LocalPlayer
local GuiService = Player.PlayerGui
local GameGUI = GuiService.GameGUI
local RNGBar = GameGUI.GameFrame.PlayableFrame.RNGBar
local RNGProgress = RNGBar.RNGP
local RNGBarFiller = RNGBar.Filler
local RNGClicker = script.Parent
local RNGMultiValue = script.Parent.RNGMulti
local RNGNumber = 0
local ClickWait = 0
local DB = 2
local canclick = 0 --might aswell replace with true or false.

local function count() --countdown function
	while wait() do
	if DB ~= 0 then
                DB = DB - 0.1
		RNGClicker.Text = ClickWait - 0.1
		wait(0.1)
	else
        
       break

end
end
end

RNGClicker.MouseButton1Click:Connect(function()
if canclick == 0 then --if the player hasnt recently clicked
canclick = 1 --the player cant click anymore
RNGNumber = math.random(1,10)
RNGProgress.Text = RNGNumber
ClickWait = 2
count()
canclick = 0 --after the function finishes the player is able to click again.
end
end)

Sorry if there’s a dumb mistake in it I didnt test, but it should work!

local PlayerService = game:GetService("Players")
local Player = PlayerService.LocalPlayer
local GuiService = Player.PlayerGui
local GameGUI = GuiService.GameGUI
local RNGBar = GameGUI.GameFrame.PlayableFrame.RNGBar
local RNGProgress = RNGBar.RNGP
local RNGBarFiller = RNGBar.Filler
local RNGClicker = script.Parent
local RNGMultiValue = script.Parent.RNGMulti
local RNGNumber = 0
local ClickWait = 0

RNGClicker.MouseButton1Click:Connect(function()
	RNGNumber = math.random(1,10)
	RNGProgress.Text = RNGNumber
	ClickWait = 2
	repeat
		ClickWait -= 0.1
		RNGClicker.Text = ClickWait - 0.1
		wait(0.1)
	until ClickWait <= 0
	ClickWait = 0
end)

You weren’t changing the value of “ClickWait” so it was always “1.9” after 0.1 was subtracted from 2, you also didn’t have a break condition (an end point for the loop) I’ve fixed both of the issues in the above.

It works, but what is that lolimage
image

Snipping this post since no longer relevant.

And the other thing, click isn’t pausing, just like text is changing, but i can click in that moment

Yeah it’s work, but it’s show only 2,1,0,-0

Snipping this post since no longer relevant.

You want to disable clicking as well? Okay.

Snipping this post since no longer relevant.

Finally, but last number is -0.1

Snipping this post since no longer relevant.

Omg, it works, but after that loop text must became like this
Click to Generate! But i don’t know where to put it lol

Snipping this post since no longer relevant.