|
| 09 Jul 2014 04:17 PM |
I scripted a block to do damage every time you touch it, but how do I add debounce to make sure that it doesn't kill me instantly every time?
Here is the script already:
function onTouch(part) local Toucher = part.Parent:FindFirstChild("Humanoid") if Toucher ~= nil then Toucher.Health = -50 end end
block = script.Parent block.Touched:connect(onTouch)
|
|
|
| Report Abuse |
|
|
|
| 09 Jul 2014 04:18 PM |
Debounce = false function onTouch(part) if not Debounce then Debounce = true local Toucher = part.Parent:FindFirstChild("Humanoid") if Toucher ~= nil then Toucher.Health = -50 wait(3) Debounce = false end end end block = script.Parent block.Touched:connect(onTouch)
|
|
|
| Report Abuse |
|
|
Tynexx
|
  |
| Joined: 11 Jul 2012 |
| Total Posts: 1559 |
|
|
| 09 Jul 2014 04:18 PM |
db =1 function onTouch(part) if db==1 then db= 0 local Toucher = part.Parent:FindFirstChild("Humanoid")
if Toucher ~= nil then Toucher:TakeDamage(50) db = 1 end end end
block = script.Parent block.Touched:connect(onTouch) |
|
|
| Report Abuse |
|
|
sayhisam1
|
  |
| Joined: 25 Nov 2009 |
| Total Posts: 2092 |
|
|
| 09 Jul 2014 04:19 PM |
function onTouch(part) local Toucher = part.Parent:FindFirstChild("Humanoid")
if Toucher ~= nil and debounce == false then debounce = true
Toucher.Health = -50
debounce = false
end
end
block = script.Parent block.Touched:connect(onTouch) |
|
|
| Report Abuse |
|
|
|
| 09 Jul 2014 04:20 PM |
| Yay thank you. The debounce almost forms a "sandwich" around the function part of the script |
|
|
| Report Abuse |
|
|