Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

So, I'm trying to make a sword to 10 damage at a time. Any help?

Asked by 5 years ago

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.

0
i have the same problem but I really dont mind Mr_Unlucky 1085 — 5y

2 answers

Log in to vote
0
Answered by 5 years ago

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)
0
oops i didnt see the script Gavinboy3000 98 — 5y
Ad
Log in to vote
0
Answered by 5 years ago

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

Answer this question