wait ()
while true do
wait ()
script.Parent.InputBox.InputEnded:Connect(function ()
print (script.Parent.InputBox.Text)
script.Parent.InputBox.Text = ""
end)
end
How whould you prevent this script from running 200 times?
wait ()
while true do
wait ()
script.Parent.InputBox.InputEnded:Connect(function ()
print (script.Parent.InputBox.Text)
script.Parent.InputBox.Text = ""
end)
end
How whould you prevent this script from running 200 times?
Hello, MageMasterHD!
To make that, do the following:
1 - Remove the While Loop
2 - Add debounce
Edited Script
wait ()
local deb = false --Debounce variable
script.Parent.InputBox.InputEnded:Connect(function () --This is a event, no loops needed =D
if (not deb) then --Test for debounce(prevent running several time)
deb = true --sets debounce to true
print (script.Parent.InputBox.Text)
script.Parent.InputBox.Text = ""
wait(5) --Debounce Time
deb = false --sets debounce to false
end
end)
Good Luck with your games
you don't need a debounce at all
@gewehrreben I Know, but its good for somone that added a event on a While Loop
I do believe there is a way to disconnect functions. I do not know much about this but I do think it works. Correct me if I am wrong.
wait ()
while true do
wait ()
clicked = script.Parent.InputBox.InputEnded:Connect(function (
print (script.Parent.InputBox.Text)
script.Parent.InputBox.Text = ""
clicked:disconnect()
end)
end
Try it and it might work but I am not 0 sure I posted this answer so that if it did work then it would help you.
Hope it works!
Why not just remove the loop?
^^^^^^^^^^^^^^^^^_^^^^^^^__^^^^^^^^^^__^_^
Also why is clicked a global variable
I said it might not work -_- now I got like no reputation.
This discussion is preserved as it was. New answers, comments, and votes are closed.
5 comments
Maybe don't wrap it in a while loop
Good idea xD
^
Once you figure out the loop part of the issue, if you still don't want the function to be called as often look into debouncing.
https://www.robloxdev.com/articles/Debounce