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 6 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 — 6y

2 answers

Log in to vote
0
Answered by 6 years ago

You need to have a debounce.

01local dmg = 10
02local debounce = false
03 
04script.Parent.Touched:connect(function(hit)
05    local char = hit.Parent
06    local human = char:FindFirstChild("Humanoid")
07 
08    if human then
09        if debounce == false then
10            debounce = true
11 
12            human:TakeDamage(dmg)
13 
14            wait(*time in between attacks*)
15            debounce = false
16        end
17    end
18end)
0
oops i didnt see the script Gavinboy3000 98 — 6y
Ad
Log in to vote
0
Answered by 6 years ago

Here, use this script that I made some changes to:

01local ATTACK_DAMAGE = 10
02local ATTACK_DELAY = 1
03 
04local rarm = script.Parent:FindFirstChild('Right Arm')
05local larm = script.Parent:FindFirstChild('Left Arm')
06 
07local debounce = false
08 
09function dmg(hit)
10    if debounce == false then
11 
12    if hit and hit.Parent then --You don't have to do "hit ~= nil" .This works the same too.
13    local char = hit.Parent
14    if char:FindFirstChild('Humanoid') then
15        debounce = true
View all 25 lines...

Read this wiki for more information: https://wiki.roblox.com/?title=Debounce

Answer this question