generic image
Processing...
  • Games
  • Catalog
  • Develop
  • Robux
  • Search in Players
  • Search in Games
  • Search in Catalog
  • Search in Groups
  • Search in Library
  • Log In
  • Sign Up
  • Games
  • Catalog
  • Develop
  • Robux
   
ROBLOX Forum » Game Creation and Development » Scripters
Home Search
 

Re: Debounce issues

Previous Thread :: Next Thread 
newcoolman2 is not online. newcoolman2
Joined: 01 Apr 2010
Total Posts: 2637
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 is not online. pandg2
Joined: 18 May 2015
Total Posts: 9
20 Jul 2016 10:37 AM
Can I see your Debounce Script?
Report Abuse
newcoolman2 is not online. newcoolman2
Joined: 01 Apr 2010
Total Posts: 2637
20 Jul 2016 10:38 AM
local debounce = false
box.FocusLost:connect(function()
if debounce == false then
print("Hi")
end
end)


Report Abuse
maxomega3 is not online. 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
StrongNuclear is not online. StrongNuclear
Joined: 05 Mar 2016
Total Posts: 963
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
newcoolman2 is not online. newcoolman2
Joined: 01 Apr 2010
Total Posts: 2637
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
newcoolman2 is not online. newcoolman2
Joined: 01 Apr 2010
Total Posts: 2637
20 Jul 2016 11:08 AM
Totally lost ;/


Report Abuse
newcoolman2 is not online. newcoolman2
Joined: 01 Apr 2010
Total Posts: 2637
20 Jul 2016 11:20 AM
rippity


Report Abuse
newcoolman2 is not online. newcoolman2
Joined: 01 Apr 2010
Total Posts: 2637
20 Jul 2016 11:42 AM
gg FocusLost


Report Abuse
Previous Thread :: Next Thread 
Page 1 of 1
 
 
ROBLOX Forum » Game Creation and Development » Scripters
   
 
   
  • About Us
  • Jobs
  • Blog
  • Parents
  • Help
  • Terms
  • Privacy

©2017 Roblox Corporation. Roblox, the Roblox logo, Robux, Bloxy, and Powering Imagination are among our registered and unregistered trademarks in the U.S. and other countries.



Progress
Starting Roblox...
Connecting to Players...
R R

Roblox is now loading. Get ready to play!

R R

You're moments away from getting into the game!

Click here for help

Check Remember my choice and click Launch Application in the dialog box above to join games faster in the future!

Gameplay sponsored by:
Loading 0% - Starting game...
Get more with Builders Club! Join Builders Club
Choose Your Avatar
I have an account
generic image