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 » Scripting Helpers
Home Search
 

Re: Explain this please...

Previous Thread :: Next Thread 
unholysoda is not online. unholysoda
Joined: 15 May 2010
Total Posts: 9024
06 Jan 2012 04:45 PM
Can someone please explain to me how to use debounce, and what the different wasy of using it are. And can you use it with debounce, db, and ting?
Report Abuse
JulienDethurens is not online. JulienDethurens
Joined: 11 Jun 2009
Total Posts: 11046
06 Jan 2012 04:47 PM
Don't ever use debounces.

It was invented by incompetent scripters that didn't know you could disconnect events.

Just disconnect your events.

Here is a door that uses the method of disconnecting events: http://www.roblox.com/Door-item?id=69286890

Much better than debounces.
Report Abuse
Chronok is not online. Chronok
Joined: 29 Dec 2011
Total Posts: 402
06 Jan 2012 04:48 PM
@Julien

example plox

{ ["Chronok"] = "Intermediate scripter/programmer." }
Report Abuse
JulienDethurens is not online. JulienDethurens
Joined: 11 Jun 2009
Total Posts: 11046
06 Jan 2012 04:50 PM
@Chronok

I did post an example.. Look at the door.

No debounce in it. Instead, it disconnects the connection.
Report Abuse
Chronok is not online. Chronok
Joined: 29 Dec 2011
Total Posts: 402
06 Jan 2012 04:56 PM
@Julien

Too lazy to use my Google Chrome extension of clickable links to get the model and look inside of it.

{ ["Chronok"] = "Intermediate scripter/programmer." }
Report Abuse
JulienDethurens is not online. JulienDethurens
Joined: 11 Jun 2009
Total Posts: 11046
06 Jan 2012 04:58 PM
Can't you just...

K, fine, Immah post the code here:

local door, connection = script.Parent, nil

function Touched(part)
   if part.Parent and game.Players:GetPlayerFromCharacter(part.Parent) then
      connection:disconnect() -- Disconnect the connection so it does nothing until we reconnect it.
      door.Transparency = 1
      door.CanCollide = false
      wait(3)
      door.Transparency = 0
      door.CanCollide = true
      connection = door.Touched:connect(Touched) -- Reconnect the connection.
   end
end

connection = door.Touched:connect(Touched)
Report Abuse
Chronok is not online. Chronok
Joined: 29 Dec 2011
Total Posts: 402
06 Jan 2012 05:00 PM
@Julien

Isn't that the exact same amount of code used to make debounce, if not more? Why type more when you can use debounce?

{ ["Chronok"] = "Intermediate scripter/programmer." }
Report Abuse
JulienDethurens is not online. JulienDethurens
Joined: 11 Jun 2009
Total Posts: 11046
06 Jan 2012 05:01 PM
Because it's more efficient and more logical.

Better memory usage, higher speed, more logical overall.
Report Abuse
unholysoda is not online. unholysoda
Joined: 15 May 2010
Total Posts: 9024
06 Jan 2012 05:06 PM
so i should use connect for my button... instead of just using debounce, i thought they were they the same, just another way of saying it.
Report Abuse
JulienDethurens is not online. JulienDethurens
Joined: 11 Jun 2009
Total Posts: 11046
06 Jan 2012 05:09 PM
No. What you really want to do when you use a debounce is to make the event stop working for some time. The best way to achieve this is to just disconnect it and reconnect it later. However, because of inexperience, players have created debounces, while, the real way to stop a connection is not to make its function return everytime called, the real way is to disconnect it.
Report Abuse
DrAgonmoray is not online. DrAgonmoray
Joined: 29 Jul 2008
Total Posts: 17428
06 Jan 2012 05:10 PM
@julien

woah ho ho!

Dr Agon here with all new event disconneting!
Tired of that old slow debounce? No just disconnect your events!
Let's hear customer testimonials!
"I am SO satisfied with this product! I can save a WHOLE BIT of memory!"
That's not all! Disconnecting events is SO much more logical, because JulienDethurens thinks so! Yup, Julien the great himself!
---

:D
Report Abuse
CrasyTrex is not online. CrasyTrex
Joined: 13 Mar 2011
Total Posts: 761
06 Jan 2012 05:10 PM
debounce is easier -_-' he just wanted it to look cooller is the only logical explanation because really the debounce works the same way but is easier.
Report Abuse
unholysoda is not online. unholysoda
Joined: 15 May 2010
Total Posts: 9024
06 Jan 2012 05:13 PM
well this is my script, im wondering where is should place them.

script.Parent.ClickDetector.MouseClick:connect(function(Player)
if Player.Name == script.Parent.Parent.Parent.OwnerName.Value then
if game.Lighting.ArtStudio1:findFirstChild("CubesBackup") == nil then
script.Parent.Parent.Parent.Cubes:Clone().Parent = game.Lighting.ArtStudio1
game.Lighting.ArtStudio1.Cubes.Name = "CubesBackup"
end


if game.Lighting.ArtStudio1:findFirstChild("Final1") == nil then
for i = 1, 400 do
m = Instance.new("BlockMesh")
m.Name = "Mesh"
m.Parent = script.Parent.Parent.Parent.Cubes:findFirstChild("Cube"..i)
wait(0.01)
end
script.Parent.Parent.Parent.Cubes:Clone().Parent = game.Lighting.ArtStudio1
game.Lighting.ArtStudio1.Cubes.Name = "Final1"
for i = 1, 400 do
script.Parent.Parent.Parent.Cubes:findFirstChild("Cube"..i).Mesh:Remove()
wait(0.01)
end
end


if game.Lighting.ArtStudio1:findFirstChild("Final1") ~= nil and
game.Lighting.ArtStudio1:findFirstChild("Final2") == nil then
for i = 1, 400 do
m = Instance.new("BlockMesh")
m.Name = "Mesh"
m.Parent = script.Parent.Parent.Parent.Cubes:findFirstChild("Cube"..i)
wait(0.01)
end
if game.Lighting.ArtStudio1:findFirstChild("Final1") ~= nil and
game.Lighting.ArtStudio1:findFirstChild("Final2") == nil then
script.Parent.Parent.Parent.Cubes:Clone().Parent = game.Lighting.ArtStudio1
game.Lighting.ArtStudio1.Cubes.Name = "Final2"
end
end




end
end)
Report Abuse
JulienDethurens is not online. JulienDethurens
Joined: 11 Jun 2009
Total Posts: 11046
06 Jan 2012 05:15 PM
...

If you disconnect a connection, it doesn't call it anymore at all.

If you use a debounce, it still gets called.

That wastes stack space, memory and is just plainly stupid.


Why do you think you can disconnect connections? You do it when you don't want a connection to be fired anymore. When you use a debounce, you precisely don't want it to be fired anymore. But, you still prefer to make the function return even though you could make it not even fire at all.


Tell me, what's the point of making a function return immediately when called when you can just make it not get called at all?

It IS logical. And it DOES use less memory.
Report Abuse
DrAgonmoray is not online. DrAgonmoray
Joined: 29 Jul 2008
Total Posts: 17428
06 Jan 2012 05:17 PM
laaaawl.
u mad bro?

srs, take a chill pill, and stoping being so egotistical. You're not better than everyone.
Report Abuse
JulienDethurens is not online. JulienDethurens
Joined: 11 Jun 2009
Total Posts: 11046
06 Jan 2012 05:18 PM
Oh.. also..

When using ClickDetectors, I prefer setting the MaxActivationDistance to 0 or putting the ClickDetector in nil temporarily.
Report Abuse
JulienDethurens is not online. JulienDethurens
Joined: 11 Jun 2009
Total Posts: 11046
06 Jan 2012 05:20 PM
"srs, take a chill pill, and stoping being so egotistical. You're not better than everyone."

I'm not. I'm just explaining why using a debounce is a bad idea because it wastes memory. Isn't that precisely the subject of this thread?
Report Abuse
DrAgonmoray is not online. DrAgonmoray
Joined: 29 Jul 2008
Total Posts: 17428
06 Jan 2012 05:24 PM
"I'm not. I'm just explaining why using a debounce is a bad idea because it wastes memory. Isn't that precisely the subject of this thread?"


Um, no.
The subject of this thread was how to use debounce, not "feed my ego and call everybody that uses debounce stupid"

I apologize to the author of this thread for this. I'll try and answer your question nao.

debounce = false --right now, our debounce is "off"
script.Parent.Touched:connect(function(h)
if debounce == false then --checking id the debounce if "off" (preferably do "if not debounce then")
debounce = true -- turn the debounce "on" so that this will not happen again unless it is off.
print('Hello world!'); --do whatever you need to here.
wait(5) --Wait a little while.
debounce = false --turn it back off.
end
end)
Report Abuse
unholysoda is not online. unholysoda
Joined: 15 May 2010
Total Posts: 9024
06 Jan 2012 05:28 PM
Ok, thanks @DrAgonmoray

so basicly if i set debounce to fasle then it will let you click it, and if its true then you can click it, or nothing will happen when you click it... Am i right?
Report Abuse
DrAgonmoray is not online. DrAgonmoray
Joined: 29 Jul 2008
Total Posts: 17428
06 Jan 2012 05:30 PM
Correct.
Report Abuse
JulienDethurens is not online. JulienDethurens
Joined: 11 Jun 2009
Total Posts: 11046
06 Jan 2012 05:31 PM
"The subject of this thread was how to use debounce"

I'm suggesting an alternative that is actually a part of the ROBLOX API.

I didn't invent disconnecting events. The ROBLOX devs did. And I never called everyone that uses debounces stupid, I said that the ones that started using debounces in the first place were probably inexperienced.
Report Abuse
DrAgonmoray is not online. DrAgonmoray
Joined: 29 Jul 2008
Total Posts: 17428
06 Jan 2012 05:35 PM
Oh, sorry for paraphrasing.
"Don't ever use debounces.
It was invented by incompetent scripters that didn't know you could disconnect events.
Just disconnect your events.
Here is a door that uses the method of disconnecting events: http://www.roblox.com/Door-item?id=69286890
Much better than debounces."

You were clearly implying something along the lines of "people who use that method of debouncing are stupid"

But I really have no desire to argue anymore with you. CLEARLY your ego is too large to think anyone else is correct. :)
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