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
 

trying to add debounce but i suck at everything

Previous Thread :: Next Thread 
Rostrum is not online. Rostrum
Joined: 03 Dec 2011
Total Posts: 26824
11 Aug 2017 10:18 AM
idk why i cant get this but someone fix this for me because i must have lost my brain cells


local debounce = false

if not debounce then
script.Parent.ClickDetector.MouseClick:Connect(function(plr)
game.ServerStorage.Key:Clone().Parent = plr.Backpack
debounce = true
end)
end



Report Abuse
Rostrum is not online. Rostrum
Joined: 03 Dec 2011
Total Posts: 26824
11 Aug 2017 10:20 AM
ah i just figured out why
because it keeps iterating through the loop and making debounce false again

but i still dont know how to fix that


Report Abuse
VisualGraphics is not online. VisualGraphics
Joined: 26 Nov 2010
Total Posts: 6515
11 Aug 2017 10:20 AM
local debounce = false

script.Parent.ClickDetector.MouseClick:Connect(function(plr)
if not debounce then
debounce = true
game.ServerStorage.Key:Clone().Parent = plr.Backpack
debounce = false
end
end)
Report Abuse
LeafDoode is not online. LeafDoode
Joined: 29 May 2017
Total Posts: 3094
11 Aug 2017 10:20 AM
try adding the statement inside the event
Report Abuse
Maliciously_Intended is not online. Maliciously_Intended
Joined: 20 May 2011
Total Posts: 975
11 Aug 2017 10:21 AM
You define debounce to be false

then, when you say if not debounce then

I think that means "if true then" which it is not true. The way you should do it is write if debounce == false then.

Also, I suggest having the function on the outside then it checks if debounce == false AFTER you click.


im not a jerk but homie u 5
Report Abuse
LeafDoode is not online. LeafDoode
Joined: 29 May 2017
Total Posts: 3094
11 Aug 2017 10:21 AM
nvm i was to late
Report Abuse
Rostrum is not online. Rostrum
Joined: 03 Dec 2011
Total Posts: 26824
11 Aug 2017 10:22 AM
thanks but it still isnt working properly for some reason

can still give myself infinite tools if i spamclick it



Report Abuse
VisualGraphics is not online. VisualGraphics
Joined: 26 Nov 2010
Total Posts: 6515
11 Aug 2017 10:22 AM
lowercase the 'c' in connect
Report Abuse
AggressiveCatch is not online. AggressiveCatch
Joined: 17 Jul 2011
Total Posts: 5840
11 Aug 2017 10:23 AM
^

that's deprecated, don't do that
Report Abuse
Maliciously_Intended is not online. Maliciously_Intended
Joined: 20 May 2011
Total Posts: 975
11 Aug 2017 10:24 AM
db = false

script.Parent.ClickDetector.MouseClick:Connect(function(plr)
if db == false then
game.ServerStorage.Key:Clone().Parent = plr.Backpack
db = true
end
end)

try this



im not a jerk but homie u 5
Report Abuse
caca50 is not online. caca50
Joined: 10 Jul 2011
Total Posts: 2037
11 Aug 2017 10:26 AM
If you want one tool, then don't set the debounce back to false.

Like actually think about what you're doing, you have it set to false, then if it's false, set it to true, do something that takes virtually no time, then set it right back to false.

Of course you can spam click it.

To have some wait time:

local db=false

function click()
if not db then
db=true
--do something
wait(someTime)
db=false
end
end


For a one time thing:

local db=false
function click()
if not db then
db=true
--do something
end
end


Roblox.Forum.Scripters:1: bad argument #1 to 'intellect' (number expected, got nil)
Report Abuse
Rostrum is not online. Rostrum
Joined: 03 Dec 2011
Total Posts: 26824
11 Aug 2017 10:27 AM
@malicious seemed to work, thank you #
Report Abuse
Maliciously_Intended is not online. Maliciously_Intended
Joined: 20 May 2011
Total Posts: 975
11 Aug 2017 10:27 AM
Also, I'm not a professional scripter or anything but for things which many players use, I tend to use boolvalues instead of db in a script. I find that it's more reliable for controlling the whole server instead of just one person. If my suggestion above still doesn't work, try adding a value in the player and change the value to true when they get the tool


im not a jerk but homie u 5
Report Abuse
Maliciously_Intended is not online. Maliciously_Intended
Joined: 20 May 2011
Total Posts: 975
11 Aug 2017 10:29 AM
to minimize chances of spamming, you can put the db = true before giving the tool as well since the script reads line to line


im not a jerk but homie u 5
Report Abuse
Sulfone is not online. Sulfone
Joined: 19 Aug 2010
Total Posts: 8046
11 Aug 2017 10:31 AM
@Maliciously_Intended
The not operator gives a value of false when given true, and vice versa.
not true -> false
not false -> true
not (variables or value that is true) -> false
not (variables or value that is false) -> true

"if debounce == false" = "if not debounce" when it comes to bools.
Report Abuse
Maliciously_Intended is not online. Maliciously_Intended
Joined: 20 May 2011
Total Posts: 975
11 Aug 2017 10:38 AM
@Sulfone but if he said debounce = false then when you do not debounce doesn't that return true?


im not a jerk but homie u 5
Report Abuse
caca50 is not online. caca50
Joined: 10 Jul 2011
Total Posts: 2037
11 Aug 2017 10:40 AM
Because when you type:

'if variable then'

It's detecting if that variable is true.

when you type:

'if not variable then'

It's detecting if the opposite of the variable is true.

Simple concept.


Roblox.Forum.Scripters:1: bad argument #1 to 'intellect' (number expected, got nil)
Report Abuse
Maliciously_Intended is not online. Maliciously_Intended
Joined: 20 May 2011
Total Posts: 975
11 Aug 2017 10:44 AM
im an idiot. I forgot how if then works. I forgot it just fires if it returns true. sorry for typing such stupidness here.


im not a jerk but homie u 5
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