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: So im using debounce

Previous Thread :: Next Thread 
xlaser23 is not online. xlaser23
Joined: 10 Dec 2011
Total Posts: 20341
25 Mar 2016 05:52 PM
im trying to add a debounce in the inputended function so it doesnt fire when the inputbegan is on a "cooldown" but im failing at it




local deb = false
local req = 5
uis.InputBegan:connect(function(input, GPE)--InputBegan
if GPE then return end
if input.KeyCode == Enum.KeyCode.E then
if deb == true then print 'cooling' return end
deb = true


wait(5)
deb = false
print 'cooled'
end
end)



uis.InputEnded:connect(function(input)--InputEnded
if input.KeyCode == Enum.KeyCode.E then
print(req)

end
end)



http://www.roblox.com/xla-item?id=290739801http://www.roblox.com/aser-item?id=290739819http://www.roblox.com/23-item?id=290739831 R$11,030 Tx70 (づ ゚ ³ ゚)づ
Report Abuse
John467583 is not online. John467583
Joined: 04 Mar 2010
Total Posts: 116
25 Mar 2016 05:56 PM
local deb = true
local req = 5
uis.InputBegan:connect(function(input, GPE)--InputBegan
if GPE then return end
if input.KeyCode == Enum.KeyCode.E then
if deb == false then print 'cooling' return end
deb = false


wait(5)
deb = true
print 'cooled'
end
end)



uis.InputEnded:connect(function(input)--InputEnded
if input.KeyCode == Enum.KeyCode.E then
print(req)

end
end)


see if this works
Report Abuse
xlaser23 is not online. xlaser23
Joined: 10 Dec 2011
Total Posts: 20341
25 Mar 2016 06:05 PM
i dont see the difference



http://www.roblox.com/xla-item?id=290739801http://www.roblox.com/aser-item?id=290739819http://www.roblox.com/23-item?id=290739831 R$11,030 Tx70 (づ ゚ ³ ゚)づ
Report Abuse
TimeTicks is not online. TimeTicks
Joined: 27 Apr 2011
Total Posts: 27115
25 Mar 2016 06:36 PM
local uis = game:GetService("UserInputService")
local debounce = false
local req = 5

uis.InputBegan:connect(function(input) --InputBegan
if input.KeyCode == Enum.KeyCode.E then
if not debounce then
debounce = true
print("Cooling")
wait(5)
debounce = false
print("Cooled")
end
end
end)

uis.InputEnded:connect(function(input) --InputEnded
if input.KeyCode == Enum.KeyCode.E and not debounce then
print(req)
end
end)
Report Abuse
xlaser23 is not online. xlaser23
Joined: 10 Dec 2011
Total Posts: 20341
26 Mar 2016 06:29 PM
keeps printing and printing

sorry for my ugly code


local req = 0 --Setting default value
local LCV --make LCV nill
local deb = false --InputBegan Debounce
local deb1 = false --InputEnded debouncce
uis.InputBegan:connect(function(input, GPE)
if GPE then return end
if input.KeyCode == Enum.KeyCode.E then
if not deb then
deb = true
req = 0
LCV = true

local human = char.Humanoid
ani.AnimationId = "http://www.roblox.com/asset?id=387149840"
if human then
local load = human:LoadAnimation(ani)
if load then
load:Play()
end
end


while LCV do
wait(1)
req = req + 1
print 'added 1'
end

wait(2)
deb = false
print 'cooled'


end
end
end)



uis.InputEnded:connect(function(input)--Aftet button was released
if input.KeyCode == Enum.KeyCode.E and not deb then
LCV = false
print(req)
ani.AnimationId = "http://www.roblox.com/asset?id=387152305"

local hu = char.Humanoid
if hu then
local load = hu:LoadAnimation(ani)
if load then
load:Play()

wait(2)
load:Stop()
end
end
end
end)



http://www.roblox.com/xla-item?id=290739801http://www.roblox.com/aser-item?id=290739819http://www.roblox.com/23-item?id=290739831 R$10,967 Tx140 (づ ゚ ³ ゚)づ
Report Abuse
xlaser23 is not online. xlaser23
Joined: 10 Dec 2011
Total Posts: 20341
26 Mar 2016 08:03 PM
some end my madness



http://www.roblox.com/xla-item?id=290739801http://www.roblox.com/aser-item?id=290739819http://www.roblox.com/23-item?id=290739831 R$11,002 Tx140 (づ ゚ ³ ゚)づ
Report Abuse
xlaser23 is not online. xlaser23
Joined: 10 Dec 2011
Total Posts: 20341
26 Mar 2016 11:18 PM
END
MY
SUFFERING
I
FEEL
LIKE
A
LOSER
RIGHT
NOW
PLS



http://www.roblox.com/xla-item?id=290739801http://www.roblox.com/aser-item?id=290739819http://www.roblox.com/23-item?id=290739831 R$11,002 Tx140 (づ ゚ ³ ゚)づ
Report Abuse
TimeTicks is not online. TimeTicks
Joined: 27 Apr 2011
Total Posts: 27115
26 Mar 2016 11:20 PM
did you try my solution
Report Abuse
xlaser23 is not online. xlaser23
Joined: 10 Dec 2011
Total Posts: 20341
26 Mar 2016 11:38 PM
yes i did

it kept printing over and over



http://www.roblox.com/xla-item?id=290739801http://www.roblox.com/aser-item?id=290739819http://www.roblox.com/23-item?id=290739831 R$11,002 Tx140 (づ ゚ ³ ゚)づ
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