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

How to fix the animation problem down to the script?

Asked by 3 years ago
Edited 3 years ago
local tool = script.Parent
local canDamage = false
local canSwing = true

local function onTouch(otherPart)

    local humanoid = otherPart.Parent:FindFirstChild("Humanoid")

    if not humanoid then 
        return 
    end

    if humanoid.Parent ~= tool.Parent and canDamage then 
        humanoid:TakeDamage(35)
    else
        return
    end

    canDamage = false
end

local function slash()
    if canSwing then
        canSwing = false
        local animation = game.Players.LocalPlayer.Character.Humanoid:LoadAnmimation{script.Parent.Attack}
        animation:Play()
        canDamage = true
        wait(1) --cooldown time
        canSwing = true
    end
end

tool.Activated:Connect(slash)
tool.Handle.Touched:Connect(onTouch)

attack is in the same tool

0
Is this a local script or a server script? If its local, you can't do game.Players Arkiteckt 38 — 3y
0
it is a local one per_chuk 17 — 3y

Answer this question