Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

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

Asked by 4 years ago
Edited 4 years ago

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)
0
while held do Azarth 3141 — 4y
0
pretty much the same problem.maybe im a big noob but it s basically the same SitaruDaniel 44 — 4y
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. Azarth 3141 — 4y

1 answer

Log in to vote
0
Answered by 4 years ago

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)


Ad

Answer this question