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)

2 comments

0

Is the Animation yours?

0

If so, then set the priority to Action.