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: Stop Gui spam click?

Previous Thread :: Next Thread 
Joseph96gr is not online. Joseph96gr
Joined: 28 Aug 2012
Total Posts: 383
08 Mar 2013 04:11 PM
I have a script in a Gui TextButton that when clicked, it would activate the script. Problem is that if you click it really fast, the function will cause a bricky supernova, and in general terms, beat the body parts off the player.... Was really funny, but made no sense at all... My concern is that is several people do this simultaneously, it will crash the server, or burn it up....
Report Abuse
Azarth is not online. Azarth
Joined: 17 Aug 2012
Total Posts: 2760
08 Mar 2013 04:14 PM
So, what do you want? The player to be only able to click the button once and never again or a wait or.. what?
Report Abuse
yomomma128 is not online. yomomma128
Joined: 13 Nov 2008
Total Posts: 23503
08 Mar 2013 04:16 PM
I guess you could add 'script.Parent.Visible = false' then a wait time, then 'script.Parent.Visible = true'
Report Abuse
As8D is not online. As8D
Joined: 24 Dec 2009
Total Posts: 2907
08 Mar 2013 04:22 PM
Hm,

---------------------------------------------------------------
local debounce = {}
local debounceTime = 10

function functionname(arguments)
if debounce["mykey"] then return end
debounce["mykey"] = true

print("STUFF OMGARSH")

wait(debounceTime)
debounce["mykey"] = nil
end
---------------------------------------------------------------


Good enough?

I hope so, I don't really know in what context you're using it. ^


- As, we must try before we can fly. That's what Shedletsky said. Or, I guess so. (Was it Kevin He?)
Report Abuse
KnightmareXD is not online. KnightmareXD
Joined: 14 Jul 2009
Total Posts: 11189
08 Mar 2013 04:23 PM
@As

This is a TextButton. Though you are on the right track.

http://wiki.roblox.com/index.php/Debounce

¤ ¤ † K M <( •д• )> X D † ¤ ¤
Report Abuse
Joseph96gr is not online. Joseph96gr
Joined: 28 Aug 2012
Total Posts: 383
08 Mar 2013 05:43 PM
well, here is the part of the script that enables the script, although i like yomomma's idea, and i dont really know how i would integrate As8D's script, so here is what i have:

script.Parent.MouseButton1Down:connect(function()
Part = Instance.new( "Part")
Part.Parent = workspace
Part.BrickColor = BrickColor.new("Black")
Part.Material = Enum.Material.Plastic
Part.Reflectance = 0.4
Part.Transparency = 0.5
Part.Name = "Part"
Part.Anchored = false
Part.CanCollide = true
Part.Elasticity = 0.5
Part.Friction = 0.30000001192093
Part.Shape = Enum.PartType.Block
Part.FormFactor = Enum.FormFactor.Symmetric
Part.Size = Vector3.new(1, 1, 1)
Part.CFrame = CFrame.new(0.5, 9.7, -6.5)
Part.BackSurface = Enum.SurfaceType.Smooth
Part.BottomSurface = Enum.SurfaceType.Smooth
Part.FrontSurface = Enum.SurfaceType.Smooth
Part.LeftSurface = Enum.SurfaceType.Smooth
Part.RightSurface = Enum.SurfaceType.Smooth
Part.TopSurface = Enum.SurfaceType.Smooth
wait(2)
end)

i know its kinda dumb to post the hole script, seeming its in one of my games, but even still, when you click the button, it makes a single brick. if you click kinda fast, it makes a bit more bricks... if you get 5 people spam clicking the button all at once, you end up with that so-called "supernova". this script will be divided from this one script doing what everyone commands, to doing what one person commands (kinda like zamsongod's city tycoon).
Report Abuse
As8D is not online. As8D
Joined: 24 Dec 2009
Total Posts: 2907
08 Mar 2013 06:18 PM
local debounce = {}
local debounceTime = 2 -- set it to whatever you like, in seconds!
local Surface = Enum.SurfaceType.Smooth -- Or string Smooth, will save you to write it all over.

function LetsMakeThatPartAwesome()
if debounce["LetsMakeThatPartAwesome"] then
return
end
debounce["LetsMakeThatPartAwesome"] = true
Part = Instance.new( "Part", workspace)
Part.BrickColor = BrickColor.new("Black")
Part.Reflectance = 0.4
Part.Transparency = 0.5
Part.FormFactor = Enum.FormFactor.Symmetric
Part.Size = Vector3.new(1, 1, 1)
Part.CFrame = CFrame.new(0.5, 9.7, -6.5)
Part.BackSurface = Surface
Part.BottomSurface = Surface
Part.FrontSurface = Surface
Part.LeftSurface = Surface
Part.RightSurface = Surface
Part.TopSurface = Surface
debounce["LetsMakeThatPartAwesome"] = nil
end)

script.Parent.MouseButton1Down:connect(function() LetsMakeThatPartAwesome() end)

-----------------------------------------------------------------------------------------------

My opinion:
You're using waaay to many lines on the same values!
Nice with anonymous functions, do you need all the properties?




- As, please replace the 'Preview >' button with shut down your computer :]!!!!
Report Abuse
As8D is not online. As8D
Joined: 24 Dec 2009
Total Posts: 2907
08 Mar 2013 06:19 PM
^ Sorry, my grammar is horrible, I have to go sleep. Byebye world!


- As, world will give me respond: byebye As.
Report Abuse
Joseph96gr is not online. Joseph96gr
Joined: 28 Aug 2012
Total Posts: 383
08 Mar 2013 07:56 PM
yes, i need all the properties. it helps to give the Part all the characteristics i want. works for just about anything in the Basic Objects, just change up some of the values
Report Abuse
togov is not online. togov
Joined: 21 Apr 2010
Total Posts: 3740
08 Mar 2013 08:21 PM
use debounce
Report Abuse
As8D is not online. As8D
Joined: 24 Dec 2009
Total Posts: 2907
09 Mar 2013 09:50 AM
@Joseph;

When you use Instance.new("Part"), the part be created. But it will need some properties, so the properties I removed are the ones IDENTICAL to the default properties. It would be nonsense to have that lines of code.

@Togov;

I used debounce in my code above, uhappy? :]



- As, what is a PM. And what is a system. What is your possibilities then?
Report Abuse
Joseph96gr is not online. Joseph96gr
Joined: 28 Aug 2012
Total Posts: 383
09 Mar 2013 03:56 PM
The default settings could be changed, which is why thy are there. i don't want the part anchored, so i have it as false, if i wanted it as a door, i could have it as true, then CanCollide false. i know some lines seem redundant, and are, but they have a purpose, so i wont remove them. thanks for your help, but it didn't work anyways. you can still spam click the part spawn
Report Abuse
As8D is not online. As8D
Joined: 24 Dec 2009
Total Posts: 2907
09 Mar 2013 04:04 PM
^ The default properties have never been changed, and won't be changed. That would ruin thousands of games.




- As, a quote from my old physics teacher: Do we have evidence that the universe is here tomorrow? NO!
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