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

Delay gets smaller and smaller every time i click a textbutton?No errrors.(ANSWERED)

For some reason the delay gets smaller and smaller every time i click it.Yea pretty much the title.Also no errors.

local held = true
script.Parent.MouseButton1Down:Connect(function(player)
	local rem = script.Parent:WaitForChild("RemoteEvent")
	rem:FireServer()
	held = true
	while true do
		wait(.3)
	if held == true then
		if script.Parent.Text ~= "2" then
			script.Parent.Text = script.Parent.Text +0.1
		end
	end
	end
end)

script.Parent.MouseButton1Up:Connect(function()
	held = false
	script.Parent.Text = 0
end)

3 comments

0

while held do

0

pretty much the same problem.maybe im a big noob but it s basically the same

0

Add an if statement on down to check if held is already true, don't run if true. Set the initial held on the top to false. Look up debounces, if you don't understand what I'm saying.

1 answer

Thank you Azarth.Figured out debounce and made it work. Here is my script.I tweaked some of it so i can add debounce to every one so im sure it deosnt get smaller.I know its messy.

local debounce = false
script.Parent.Parent.bly.MouseButton2Down:Connect(function()
	script.Parent.Visible = true
	debounce = false
	wait(.1)
	if not debounce then
		script.Parent.Text = script.Parent.Text +0.1
		wait(.1)
	if not debounce then
		script.Parent.Text = script.Parent.Text +0.1
		wait(.1)
	if not debounce then
		script.Parent.Text = script.Parent.Text +0.1
		wait(.1)
	if not debounce then
		script.Parent.Text = script.Parent.Text +0.1
		wait(.1)
	if not debounce then
		script.Parent.Text = script.Parent.Text +0.1
		wait(.1)
	if not debounce then
		script.Parent.Text = script.Parent.Text +0.1
		wait(.1)
	if not debounce then
		script.Parent.Text = script.Parent.Text +0.1
		wait(.1)
	if not debounce then
		script.Parent.Text = script.Parent.Text +0.1
		wait(.1)
	if not debounce then
		script.Parent.Text = script.Parent.Text +0.1
		wait(.1)
	if not debounce then
		script.Parent.Text = script.Parent.Text +0.1
		wait(.1)
	if not debounce then
		script.Parent.Text = script.Parent.Text +0.1
		wait(.1)
	if not debounce then
		script.Parent.Text = script.Parent.Text +0.1
		wait(.1)
	if not debounce then
		script.Parent.Text = script.Parent.Text +0.1
		wait(.1)
	if not debounce then
		script.Parent.Text = script.Parent.Text +0.1
		wait(.1)
	if not debounce then
		script.Parent.Text = script.Parent.Text +0.1
		wait(.1)
	if not debounce then
		script.Parent.Text = script.Parent.Text +0.1
		wait(.1)
	if not debounce then
		script.Parent.Text = script.Parent.Text +0.1
		wait(.1)
	if not debounce then
		script.Parent.Text = script.Parent.Text +0.1
		wait(.1)
	if not debounce then
		script.Parent.Text = script.Parent.Text +0.1
		wait(.1)
	if not debounce then
		script.Parent.Text = script.Parent.Text +0.1
		end
		end
		end
		end
		end
		end
		end
		end
		end
		end
		end
		end
		end
		end
		end
		end
		end
		end
		end
	end
end)

script.Parent.Parent.bly.MouseButton2Up:Connect(function()
	script.Parent.Visible = false
	script.Parent.Text = 0
	debounce = true
end)


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