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: How to correctly debounce this script?

Previous Thread :: Next Thread 
fireflame09225 is not online. fireflame09225
Joined: 04 Jan 2010
Total Posts: 1818
20 Apr 2013 08:14 AM
So, I tried looking on the wiki, and just randomly testing things out to try and debounce this script, so the player only get's ONE win, not 10...

Here is the script:

function Touched(hit)
local hum = hit.Parent:FindFirstChild("Humanoid")
if hum ~= nil then
local char = hum.Parent
if char ~= nil then
script.Parent.Parent.Winner.Value = char
print("found")

wait()

local plr = game.Players:GetPlayerFromCharacter(char)
plr.leaderstats.Wins.Value = plr.leaderstats.Wins.Value + 1
end
end
end

script.Parent.Touched:connect(Touched)


Like I said, I tried quite a few ways, without any luck.
Report Abuse
fireflame09225 is not online. fireflame09225
Joined: 04 Jan 2010
Total Posts: 1818
20 Apr 2013 08:24 AM
Anyone? Help?
Report Abuse
Kepie is not online. Kepie
Joined: 12 Nov 2011
Total Posts: 884
20 Apr 2013 08:29 AM
function Touched(hit)
local hum = hit.Parent:FindFirstChild("Humanoid")
if hum ~= nil then
local char = hum.Parent
if char ~= nil then
script.Parent.Parent.Winner.Value = char
print("found")

wait()
deb = false
local plr = game.Players:GetPlayerFromCharacter(char)
deb = true
plr.leaderstats.Wins.Value = plr.leaderstats.Wins.Value + 1
end
end
end

script.Parent.Touched:connect(Touched)
Report Abuse
veerstrong is not online. veerstrong
Joined: 23 Jun 2009
Total Posts: 2450
20 Apr 2013 08:30 AM
debounce = false
script.Parent.Touched:connect(function(p)
if not debounce then
debounce = true
local hum = hit.Parent:FindFirstChild("Humanoid")
if hum ~= nil then
local char = hum.Parent
if char ~= nil then
script.Parent.Parent.Winner.Value = char
print("found")
local plr = game.Players:GetPlayerFromCharacter(char)
plr.leaderstats.Wins.Value = plr.leaderstats.Wins.Value + 1
wait(2)
debounce = false
end
end
end
end)

~One must risk everything to find the truth. Even if the truth isn't what you want it to be, it is better than living a lie.~
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