How to make completely new player animations upon equipping tool

I already tried disabling the original animations script and replacing with new,but it didnt work,and also tried changing the animations value,but that also doesnt work,any solutions?

This is actually one of my replies from another post, but it still works for any tool.


local Humanoid = script.Parent.Parent:FindFirstChild("Humanoid")
local Animation = script.Parent.Animation

if Humanoid and Humanoid.Health > 0 then

   local Animator = Humanoid:FindFirstChild("Animator") or Humanoid
   local PlayAnim = Animator:LoadAnimation(Animation)

   PlayAnim:Play()
end
end)

Add an Animation instance inside of the tool, and put this code in a LocalScript that’s inside of the tool.

If you need an explanation of what’s happening in the code above, let me know.

1 Like

Not death animations though,more like running and jumping etc

That was one mistake that shouldn’t have been in the script. Meant to do > instead of <.

But for that, like I’m doing for my weapon you should make your own animation table (kind of like the one thats in the players animate script) and you can go from there.

Something like this:

Animations = {

Idle = {ID = "rbxassetid://", Name = "ToolIdleAnim"},
Run = {ID = "rbxassetid://", Name = "ToolRunAnim"},
Jump = {ID = "rbxassetid://", Name = "ToolJumpAnim"},

SwingAttacks = {
    Swing1 = {ID = "rbxassetid://", Name = "Swing1"},
    Swing2 = {ID = "rbxassetid://", Name = "Swing2"},
    Swing3 = {ID = "rbxassetid://", Name = "Swing3"},
    Swing4 = {ID = "rbxassetid://", Name = "Swing4"},
},


Equipped = {ID = "rbxassetid://", Name = "ToolEquippedAnim"},
Unequipped = {ID = "rbxassetid://", Name = "ToolUnequippedAnim"},

}

And instead of the above script you can make it so that if the tool IS equipped, it’ll get the state of the players humanoid.

local Humanoid = script.Parent.Parent:FindFirstChild("Humanoid")
local Animator = Humanoid:FindFirstChild("Animator") or Humanoid

function PlayAnim(animID, name, weight, speed, fade)

    local Animation = Instance.new("Animation")

    Animation.AnimationId = tostring(animID)
    Animation.Name = name

    local animLoad = Animator:LoadAnimation(Animation)
    
    animLoad:AdjustWeight(weight)
    animLoad:AdjustSpeed(speed)
    animLoad:Play(fade)
end

function StopAnim(animID, name, fade)

    local Animation = Instance.new("Animation")

    Animation.AnimationId = tostring(animID)
    Animation.Name = name

    local animLoad = Animator:LoadAnimation(Animation)
    
    animLoad:Stop(fade)
end


script.Parent.Equipped:Connect(function()
if Humanoid and Humanoid.Health > 0 then

    if Humanoid:GetState() == Enum.HumanoidStateType.Running then

        PlayAnim(Animation.Run.ID, Animation.Run.Name, 4, 0.9)
        StopAnim(Animation.Idle.ID, Animation.Idle.Name)

    elseif Humanoid:GetState() == Enum.HumanoidStateType.PlatformStanding then

        PlayAnim(Animation.Idle.ID, Animation.Idle,Name, 3, 0.7)
        StopAnim(Animation.Run.ID, Animation.Run.Name)
    end
end
end)

As much as this looks legit, I don’t necessarily recommend you using the way I controlled the animations. But it’s like a general way of making your own animation table.

2 Likes

alr thanks man ill try it out and see if i can get it to work

Let me know how it goes, error-wise and also just anything that might’ve messed some things up.

1 Like

Hey it worked perfectly thanks for the help

1 Like

You’re welcome! If you need anything else you can ask DevForum, or if you want some personal help you can PM me.

1 Like
Players = game:GetService("Players")
repeat wait() until Players.LocalPlayer.CharacterAppearanceLoaded
PlayerCharacter = game.Players.LocalPlayer.Character

CharHumanoid = PlayerCharacter:FindFirstChild("Humanoid")



Animations = {

	Idle = {ID = "rbxassetid://9512495117", Name = "ToolIdleAnim"},
	Run = {ID = "rbxassetid://9523550546", Name = "ToolRunAnim"},
	Jump = {ID = "rbxassetid://", Name = "ToolJumpAnim"},




	Equipped = {ID = "rbxassetid://9552333661", Name = "ToolEquippedAnim"},
	Unequipped = {ID = "rbxassetid://", Name = "ToolUnequippedAnim"},
}
idle = true

function GetAnim(animID, name, weight, speed, fade)
	local Humanoid = script.Parent.Parent:FindFirstChild("Humanoid")
	local Animator = Humanoid:WaitForChild("Animator")
	local Animation = Instance.new("Animation")

	Animation.AnimationId = tostring(animID)
	Animation.Name = name

	local animLoad = Animator:LoadAnimation(Animation)

	animLoad:AdjustWeight(weight)
	animLoad:AdjustSpeed(speed)

	return animLoad
end

print(CharHumanoid.Parent.Name)




script.Parent.Equipped:Connect(function()
	local RunAnimIsPlaying = false
	local IdleAnimIsPlaying = false

	local CanPlayRunAnim = true
	local CanPlayIdleAnim = true

	local Humanoid = script.Parent.Parent:FindFirstChild("Humanoid")
	local Animator = Humanoid:WaitForChild("Animator")


	local RunAnim = GetAnim(Animations.Run.ID, Animations.Run.Name)
	local IdleAnim = GetAnim(Animations.Idle.ID, Animations.Idle.Name)






	local function Running()
		if Humanoid:GetState() == Enum.HumanoidStateType.Running then
			if Humanoid.MoveDirection.Magnitude >= 1 then
				if RunAnimIsPlaying == true then

				else
					RunAnim:Play()
					IdleAnim:Stop()

					RunAnimIsPlaying = true
					IdleAnimIsPlaying = false
				end


			
			else
				if Humanoid.MoveDirection.Magnitude == 0 then
					if IdleAnimIsPlaying == true then
						
					else
						print("got none")
						IdleAnim:Play()
						RunAnim:stop()

						RunAnimIsPlaying = false
						IdleAnimIsPlaying = true	
					end
					
				end
			end
		end
			
		end
			




	while true do
		wait(0.0001)





		Running()
	end



end)