#Start Animation when player has equiped a tool and clicked.

6 messages · Page 1 of 1 (latest)

marsh sedge
#

do you have an anim already? @quiet shadow

quiet shadow
#
local tool = script.Parent  
local player = game.Players.LocalPlayer  
local animation = tool:WaitForChild("Animations"):WaitForChild("Trivela")  


local function playAnimation()
    local character = player.Character or player.CharacterAdded:Wait()  
    local humanoid = character:WaitForChild("Humanoid")  


    if not humanoid:FindFirstChild("Animator") then
        local animator = Instance.new("Animator")
        animator.Parent = humanoid
    end


    local animationTrack = humanoid:LoadAnimation(animation)
    animationTrack.Priority = Enum.AnimationPriority.Action 
    animationTrack:Play()  
end


tool.Equipped:Connect(function()

    local userInputService = game:GetService("UserInputService")


    userInputService.InputBegan:Connect(function(input, gameProcessedEvent)

        if not gameProcessedEvent and input.KeyCode == Enum.KeyCode.Q then
            playAnimation()  
        end
    end)
end)
#

the script

#

idk why it isnt working

quiet shadow
#

fixed it myself