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

Problem playing animation while having a tool (¿?)

Asked by 6 years ago

I'm making a sword, and i want the animation to play when the player clicks but the animation doesn't play, it even prints PLAYED when i click, but just that. Any solution to that?

local player = game.Players.LocalPlayer
local Character = game.Workspace:WaitForChild(player.Name)
local animation = script.Parent.AttackAnim

script.Parent.Equipped:Connect(function(mouse)

    local weld = Instance.new("WeldConstraint")
        weld.Parent = player
        weld.Name = "AnimWeld"
        weld.Part0 = Character:FindFirstChild("RightHand")
        weld.Part1 = script.Parent.Handle
    local anim = Character.Humanoid:LoadAnimation(animation)

     game:GetService("UserInputService").InputBegan:Connect(function(input, gui)

        if (game.Players.LocalPlayer.Character:FindFirstChild("Sword")) then
            if (input.UserInputType == Enum.UserInputType.MouseButton1 and gui == false) then         
                anim:Play()             
                print("PLAYED")         
            end            
        end                
    end)   
end)

script.Parent.Unequipped:Connect(function() 
    player:FindFirstChild("AnimWeld"):Destroy() 
end)
0
Is the Animation yours? piRadians 297 — 6y
0
If so, then set the priority to Action. piRadians 297 — 6y

Answer this question