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

Sword isn't dealing damage. What's wrong?

Asked by 6 years ago

(Note: Game is filtered enabled) (Note: There are no errors in output)

SCRIPT

local sword = script.Parent
local swing = sword:WaitForChild('swingSword')
local taked = sword:WaitForChild('takedamage')

local swinging = false


swing.OnServerEvent:Connect(function()
    local char = sword.Parent
    local hum = char:WaitForChild('Humanoid')

    local anim = hum:LoadAnimation(sword.katanaSlash)
    anim:Play()
    swinging = true
    anim:AdjustSpeed(2)
    wait(1.5)
    swinging = false
end)


local ten = false

sword.BladeBlack.Touched:Connect(function(hit)
    if ten == true then return end
    ten = true
    if swinging == true then return end
    if hit and hit.Parent:FindFirstChild('Humanoid') then
        hit.Parent:FindFirstChild('Humanoid'):TakeDamage(20)
        ten = false
    end
end)

LOCALSCRIPT

local sword = script.Parent
local swing = sword:WaitForChild('swingSword')
local taked = sword:WaitForChild('takedamage')

local en = false
local swinging = false
sword.Activated:Connect(function()
    if en  == true then return end
    en = true
    if swinging == true then return end
    swing:FireServer()
    swinging = true
    wait(1.5)
    swinging = false
    en = false
end)




1
Line 26 on your server side script, you're checking that if the blade is swung then stop doing the code? I believe that needs to be false instead. xPolarium 1388 — 6y

Answer this question