My script is not working

Hello, I was working with tools but my idle animation gets overwritten by the tool
I made this script to fix the problem, but it isn’t working

local plr = game.Players.LocalPlayer
local replicatedStorage = game:GetService("ReplicatedStorage")

script.Parent.Equipped:Connect(function()




	local Track2 = Instance.new("Animation")
	Track2.AnimationId = "rbxassetid://6382914177" --Idle 
	local Anim2 = plr.Character.Humanoid:LoadAnimation(Track2)
	Anim2:Play()



end)


script.Parent.Unequipped:Connect(function()
	
	local Track2 = Instance.new("Animation")
	Track2.AnimationId = "rbxassetid://6382914177" --Idle 
	local Anim2 = plr.Character.Humanoid:LoadAnimation(Track2)

	Anim2:Stop()





end)

Does anyone know why?

Is your animation Priority set to Action?

Yes, I just checked
30 letters

This should do:

local plr = game.Players.LocalPlayer
local tool = script.Parent
local char = tool.Parent:IsA("Model") and tool.Parent or tool.Parent:IsA("Backpack") and plr.Character
local hum = char:WaitForChild("Humanoid")
local animator = hum:WaitForChild("Animator")

local anim2 = Instance.new("Animation")
anim2.AnimationId = "rbxassetid://6382914177"

local track2 = animator:LoadAnimation(anim2)

script.Parent.Equipped:Connect(function()
	track2:Play()
end)


script.Parent.Unequipped:Connect(function()
	track2:Stop()
end)

If you want me to explain everything, just say so!

1 Like

Unfortunately, it doesn’t seem to work

The idle is looping, right? Char 30

Yes
30 letters again 30 letters

local Tool = script.Parent
local anim2 = Instance.new("Animation")
anim2.AnimationId = "rbxassetid://6382914177"

Tool.Equipped:Connect(function()
local Character = Tool.Parent
anim2.Parent = Character
local track2 = Character.Humanoid:LoadAnimation(anim2)
	track2:Play()
Tool.Unequipped:Connect(function()
	track2:Stop()
end)
end)

Still nothing, pretty weird
char 30

I edited the script, try again

1 Like