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

How to animate an arm that is holding a tool? (with the tool ofcourse)

Asked by 6 years ago
local tool = script.Parent
local handle = script.Parent:WaitForChild('Handle')

local Debounce = true
local slash = script.Parent:WaitForChild('Slash')

local click = false
local inAttack = false

tool.Activated:connect(function()
    inAttack = true
    if Debounce then
        Debounce = false
        click = true
        print('tool activated')

        local plr = game.Players:GetPlayerFromCharacter(tool.Parent)

        if plr then 
            handle.Touched:connect(function(hit)
                if inAttack then

                    print('animation')

                    -- Animation

                        local char = plr.Character
                        if char then
                            local hum = char:WaitForChild('Humanoid')
                            local slashTrack = hum:LoadAnimation(slash)
                            wait(0.1)
                            slashTrack:Play()
                        end

                    -- Tree damage

                    if hit.Parent and hit.Parent.Name ~= plr.Name and hit.Parent:FindFirstChild('Wood') then
                        wait(0.1)
                        local HP = hit.Parent.HP
                        HP.Value = HP.Value - 30
                    end

                else
                    print(Debounce)
                    print(click)
                end
            end)
        end

        wait(0.5)
        click = false

        wait(5)

        Debounce = true
    end
end)

Server script inside a tool in starterpack, this script isn't done! The problem is, the animation starts but it doesn't animate the arm holding the tool, and I'm a bit scared that the tool might not animate with it even if it was working, any ideas on how to do it?

0
I did this with a gun I made make sure when you make the animation always play no matter what the player is doing the animation action needs to be set to action, to ensure it doesn't get overridden by the default run jump etc.. Hope this helps TheGreatSailor 20 — 6y
0
How? User#20388 0 — 6y
0
nvm, found it, thanks a lot User#20388 0 — 6y
0
I would have the animation function in the activated function if the animation would play when the tool was activated, then you just animate the arm and the tool should go with it. WorkAtChickenPlace 19 — 6y

Answer this question