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
We use cookies to offer you a better experience. By using Roblox.com, you are agreeing to our Privacy and Cookie Policy.
   
ROBLOX Forum » Game Creation and Development » Scripting Helpers
Home Search
 

Re: fix my debouncing?

Previous Thread :: Next Thread 
drahsid5 is not online. drahsid5
Joined: 13 May 2011
Total Posts: 3937
27 Feb 2014 08:36 PM
I suck with debouncing, can someone fix it?

repeat wait() until game.Players.LocalPlayer
local db = true
local down = false
local p = game.Players.LocalPlayer
db = false

local firstClick = 0

p:GetMouse().KeyDown:connect(function(key)
if key:byte() == 32 then
if firstClick == 0 then
firstClick = tick()
db = true
elseif firstClick ~= 0 then
calc = (tick() - firstClick)
firstClick = 0
db = false
if calc >= 0 and calc <= 2.1 and db == false then
p.Character.Torso.Velocity = p.Character.Torso.Velocity + Vector3.new(0,20,0)
end
end
end
end)
Report Abuse
drahsid5 is not online. drahsid5
Joined: 13 May 2011
Total Posts: 3937
27 Feb 2014 08:56 PM
bump
Report Abuse
drahsid5 is not online. drahsid5
Joined: 13 May 2011
Total Posts: 3937
27 Feb 2014 09:02 PM
bump
Report Abuse
drahsid5 is not online. drahsid5
Joined: 13 May 2011
Total Posts: 3937
27 Feb 2014 09:10 PM
I debouncing really as hard as I think?
Report Abuse
drahsid5 is not online. drahsid5
Joined: 13 May 2011
Total Posts: 3937
27 Feb 2014 09:20 PM
.-. bump
Report Abuse
drahsid5 is not online. drahsid5
Joined: 13 May 2011
Total Posts: 3937
27 Feb 2014 09:28 PM
I love when the forum helps me. :P
Report Abuse
drahsid5 is not online. drahsid5
Joined: 13 May 2011
Total Posts: 3937
27 Feb 2014 09:37 PM
That was sarcasm btw.
Report Abuse
drahsid5 is not online. drahsid5
Joined: 13 May 2011
Total Posts: 3937
27 Feb 2014 09:48 PM
Is this complex for you all?
.-.
If you didn't know; "db" is debcounce.
Report Abuse
Zkiller11 is not online. Zkiller11
Joined: 25 Aug 2009
Total Posts: 2914
27 Feb 2014 09:54 PM
repeat wait() until game.Players.LocalPlayer
local db = true
local down = false
local p = game.Players.LocalPlayer

local firstClick = 0

p:GetMouse().KeyDown:connect(function(key)
if key:byte() == 32 then
if firstClick == 0 then
if db then
firstClick = tick()
db = false
elseif firstClick ~= 0 then
calc = (tick() - firstClick)
firstClick = 0
if calc >= 0 and calc <= 2.1 and db == false then
p.Character.Torso.Velocity = p.Character.Torso.Velocity + Vector3.new(0,20,0)
d = true
end
end
end
end
end)

Something like that
Report Abuse
drahsid5 is not online. drahsid5
Joined: 13 May 2011
Total Posts: 3937
27 Feb 2014 10:05 PM
didn't work. But thanks for trying. ;)
Report Abuse
drahsid5 is not online. drahsid5
Joined: 13 May 2011
Total Posts: 3937
27 Feb 2014 10:18 PM
bump
Report Abuse
V0xels is not online. V0xels
Joined: 30 Mar 2012
Total Posts: 2072
27 Feb 2014 10:21 PM
LocalScript right?
Report Abuse
islandmaker2012 is not online. islandmaker2012
Joined: 07 Nov 2012
Total Posts: 9327
27 Feb 2014 10:22 PM
db = false
function whatevs()
if not db then
--dostuff
db = true
wait(2)
db = false
else
--ignorin cuz we iz waitin!
end
end
whatevs()
Report Abuse
drahsid5 is not online. drahsid5
Joined: 13 May 2011
Total Posts: 3937
27 Feb 2014 10:26 PM
yes, a local script.
Report Abuse
drahsid5 is not online. drahsid5
Joined: 13 May 2011
Total Posts: 3937
27 Feb 2014 10:28 PM
Island, didn't work.
Report Abuse
islandmaker2012 is not online. islandmaker2012
Joined: 07 Nov 2012
Total Posts: 9327
27 Feb 2014 10:33 PM
obviously u did something rong then..
the way I said it,is the way debounce is..
var = false
function functionname(arguments)
if var == false then
var = true
print "waiting 2 seconds before this can happen again"
wait(2)
var = false
else
print "wait a second!we are still waiting for var to be false!"
end
end

Workspace.Part.Touched:connect(functionname)
Report Abuse
drahsid5 is not online. drahsid5
Joined: 13 May 2011
Total Posts: 3937
27 Feb 2014 10:35 PM
The script is a double jump script, if that helps.
Report Abuse
islandmaker2012 is not online. islandmaker2012
Joined: 07 Nov 2012
Total Posts: 9327
27 Feb 2014 10:36 PM
hey,just realized
Zkillers should work,but on the last line he had db spelt rong
he said
d = true--or false
and it should've been db
try fixing that last line and testing Zkillers again :)
Report Abuse
drahsid5 is not online. drahsid5
Joined: 13 May 2011
Total Posts: 3937
27 Feb 2014 10:37 PM
I did fix Zkiller's, nothing happened when I hit space twice.
Report Abuse
islandmaker2012 is not online. islandmaker2012
Joined: 07 Nov 2012
Total Posts: 9327
27 Feb 2014 10:38 PM
oh
d@rnit..
I have no idea why it wouldn't work then..
Report Abuse
drahsid5 is not online. drahsid5
Joined: 13 May 2011
Total Posts: 3937
27 Feb 2014 10:41 PM
xD
well, if there were a method for detecting if the player is in the air, I wouldn't need this.
Report Abuse
V0xels is not online. V0xels
Joined: 30 Mar 2012
Total Posts: 2072
27 Feb 2014 10:47 PM
Why dont you do it easy way?

local plr = game.Players.LocalPlayer
local plrMouse = plr:GetMouse()
local air = false

plrMouse.KeyDown:connect(function()
if key == and air == false then-- Spacebar key
air = true
elseif key == "spacebar here" and air == true then
-- Blah blah code
end)
Report Abuse
V0xels is not online. V0xels
Joined: 30 Mar 2012
Total Posts: 2072
27 Feb 2014 10:48 PM
Add wait()'s and such to time it better. Forgot to do that
Report Abuse
drahsid5 is not online. drahsid5
Joined: 13 May 2011
Total Posts: 3937
27 Feb 2014 10:51 PM
I'm bewildered in how I'd properly transfer my code to that, and why not refer to the key value I already had for space bar (32) ?
Report Abuse
V0xels is not online. V0xels
Joined: 30 Mar 2012
Total Posts: 2072
27 Feb 2014 10:52 PM
if key:byte() == 32 and air == false then

elseif key:byte() == 32 and air == true then
Report Abuse
Previous Thread :: Next Thread 
Page 1 of 1
 
 
ROBLOX Forum » Game Creation and Development » Scripting Helpers
   
 
   
  • 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