https://gyazo.com/fa223dee783ba1ddf28f8a093e7263d5
This script doesn't work and i don't know whats wrong with it. I mean it kills the "humanoid", but doesn't do 10 damage at a time, it just kills it instantly.
https://gyazo.com/fa223dee783ba1ddf28f8a093e7263d5
This script doesn't work and i don't know whats wrong with it. I mean it kills the "humanoid", but doesn't do 10 damage at a time, it just kills it instantly.
You need to have a debounce.
local dmg = 10
local debounce = false
script.Parent.Touched:connect(function(hit)
local char = hit.Parent
local human = char:FindFirstChild("Humanoid")
if human then
if debounce == false then
debounce = true
human:TakeDamage(dmg)
wait(*time in between attacks*)
debounce = false
end
end
end)
oops i didnt see the script
Here, use this script that I made some changes to:
local ATTACK_DAMAGE = 10
local ATTACK_DELAY = 1
local rarm = script.Parent:FindFirstChild('Right Arm')
local larm = script.Parent:FindFirstChild('Left Arm')
local debounce = false
function dmg(hit)
if debounce == false then
if hit and hit.Parent then --You don't have to do "hit ~= nil" .This works the same too.
local char = hit.Parent
if char:FindFirstChild('Humanoid') then
debounce = true
local hum = char.Humanoid
hum:TakeDamage(ATTACK_DAMAGE)
wait(ATTACK_DELAY)
debounce = false
end
end
end
rarm.Touched:connect(dmg)
larm.Touched:connect(dmg)
Read this wiki for more information: https://wiki.roblox.com/?title=Debounce
This discussion is preserved as it was. New answers, comments, and votes are closed.
1 comment
i have the same problem but I really dont mind