|
| 20 Jul 2016 10:32 AM |
I am using textbox.FocusLost It seems to not like debounce as it runs multiple times. I put multiple debounces in various places and still not working I tried so much. What does FocusLost do to make it run many times.
|
|
|
| Report Abuse |
|
|
pandg2
|
  |
| Joined: 18 May 2015 |
| Total Posts: 9 |
|
|
| 20 Jul 2016 10:37 AM |
| Can I see your Debounce Script? |
|
|
| Report Abuse |
|
|
|
| 20 Jul 2016 10:38 AM |
local debounce = false box.FocusLost:connect(function() if debounce == false then print("Hi") end end)
|
|
|
| Report Abuse |
|
|
maxomega3
|
  |
| Joined: 11 Jun 2010 |
| Total Posts: 10668 |
|
|
| 20 Jul 2016 10:45 AM |
you're missing the crucial aspect of the debounce where you change the value of the debounce while printing 'Hi' to true and then set it to false when the operation is done.
local debounce = false box.FocusLost:connect (function () if not debounce then -- a cleaner way of saying == false debounce = true -- preventing the function from running again before what's below is finished print ("Hi") wait () -- useful if you want the debounce to be longer than it takes for the meat of the code to run debounce = false -- letting the function's code run again if triggered end end)
|
|
|
| Report Abuse |
|
|
|
| 20 Jul 2016 10:45 AM |
| You need to set debounce to true after the conditional code wait() then set it back to false. |
|
|
| Report Abuse |
|
|
|
| 20 Jul 2016 10:53 AM |
Yikes I missed some stuff out because I was shortening it for the forums
But everything you guys said did not work.
You guys can put this into a local script or into the command bar to test it.
game:GetService('StarterGui'):SetCoreGuiEnabled(Enum.CoreGuiType.All, false) game:GetService('StarterGui').ResetPlayerGuiOnSpawn = false local player = game.Players.LocalPlayer local gui = Instance.new("ScreenGui", player.PlayerGui) gui.Name = "Chat1" local button = Instance.new("TextBox",gui) button.Size = UDim2.new(0,0,0,0) local box = player.PlayerGui:WaitForChild"Chat1".TextBox game:GetService"UserInputService".InputBegan:connect(function(key, gpe) if key.KeyCode == Enum.KeyCode.Slash and not gpe then box.Position = UDim2.new(0,0,1,-14) box.Size = UDim2.new(1,0,0,14) box.Transparency = .69 box.Active = true box:CaptureFocus() end local debounce = false box.FocusLost:connect(function() if not debounce then debounce = true print("Hi") wait() debounce = false end end) end)
|
|
|
| Report Abuse |
|
|
| |
|
| |
|
| |
|