Animations not working in tools

just to make things clear:
-where do you want to play the animation? on the script, or local script?
-Which one is the script, and which one is the local script?

image

it looks like you have your local script disabled

I want to make animations work in server scripts and the disabled scripts are the ones I don’t use

local ReplicatedStorage = game:GetService("ReplicatedStorage")
local Players = game:GetService("Players")

local eventClean = ReplicatedStorage:WaitForChild("eventclean")

eventClean.OnClientEvent:Connect(function(player, spill)
	warn('Event Called!')

	local character = player.Character or player.CharacterAdded:Wait()
	local humanoid = character:FindFirstChildOfClass("Humanoid")
	warn('Character =', character, "AND humanoid =", humanoid)

	local animator = humanoid:FindFirstChildOfClass("Animator")

	local tool = script.Parent
	
	if animator then
		warn('Loaded Animator!')
		local anim = Instance.new("Animation")
		anim.AnimationId = "rbxassetid://126407570972225" -- βœ… μ΄λ ‡κ²Œ 고쳐야 함
		animationTrack = animator:LoadAnimation(anim)
		animationTrack:Play()

		task.delay(3, function()
			if animationTrack then
				animationTrack:Stop()
			end
		end)
	end

	

end)

this local script?

yes, is it enabled or not enabled?

Ah, the one you sent me earlier was a different script log.
Even when I test it with the script you sent me, no log appears.

Okay, I think I got it, the server script is not getting called because you are not calling the event, so just for testing replace:

local ReplicatedStorage = game:GetService("ReplicatedStorage")
local Players = game:GetService("Players")

local eventClean = ReplicatedStorage:WaitForChild("eventclean")

eventClean.OnClientEvent:Connect(function(player, spill)
	warn('Event Called!')

	local character = player.Character or player.CharacterAdded:Wait()
	local humanoid = character:FindFirstChildOfClass("Humanoid")
	warn('Character =', character, "AND humanoid =", humanoid)

	local animator = humanoid:FindFirstChildOfClass("Animator")

	local tool = script.Parent
	
	if animator then
		warn('Loaded Animator!')
		local anim = Instance.new("Animation")
		anim.AnimationId = "rbxassetid://126407570972225" -- βœ… μ΄λ ‡κ²Œ 고쳐야 함
		local animationTrack = animator:LoadAnimation(anim)
		animationTrack:Play()

		task.delay(3, function()
			if animationTrack then
				animationTrack:Stop()
			end
		end)
	end
end)

with this to debug:

local ReplicatedStorage = game:GetService("ReplicatedStorage")
local Players = game:GetService("Players")

local eventClean = ReplicatedStorage:WaitForChild("eventclean")

wait(10)
	warn('Event Called!')

	local character = player.Character or player.CharacterAdded:Wait()
	local humanoid = character:FindFirstChildOfClass("Humanoid")
	warn('Character =', character, "AND humanoid =", humanoid)

	local animator = humanoid:FindFirstChildOfClass("Animator")

	local tool = script.Parent
	
	if animator then
		warn('Loaded Animator!')
		local anim = Instance.new("Animation")
		anim.AnimationId = "rbxassetid://126407570972225" -- βœ… μ΄λ ‡κ²Œ 고쳐야 함
		local animationTrack = animator:LoadAnimation(anim)
		animationTrack:Play()

		task.delay(3, function()
			if animationTrack then
				animationTrack:Stop()
			end
		end)
	end

now, what are the logs that you got?

where is player?
and is local script?


What?

opps, then try:

local ReplicatedStorage = game:GetService("ReplicatedStorage")
local Players = game:GetService("Players")

local eventClean = ReplicatedStorage:WaitForChild("eventclean")

script.Parnet.Equipped:Connect(function()
    print("Tool has been equipped!")
	warn('Event Called!')
    player = Players:FindFirstChild(script.Parent.Parent.Name)

	local character = player.Character or player.CharacterAdded:Wait()
	local humanoid = character:FindFirstChildOfClass("Humanoid")
	warn('Character =', character, "AND humanoid =", humanoid)

	local animator = humanoid:FindFirstChildOfClass("Animator")

	local tool = script.Parent
	
	if animator then
		warn('Loaded Animator!')
		local anim = Instance.new("Animation")
		anim.AnimationId = "rbxassetid://126407570972225" -- βœ… μ΄λ ‡κ²Œ 고쳐야 함
		local animationTrack = animator:LoadAnimation(anim)
		animationTrack:Play()

		task.delay(3, function()
			if animationTrack then
				animationTrack:Stop()
			end
		end)
	end
end)

just equip the mop, to debug

Now, what logs do you get after equipping?

This will help find the problem

21:42:15.169 Parnet is not a valid member of LocalScript β€œPlayers.xptmxmgkfj.Backpack.Mop.LocalScript”

Check Output for errors. sometimes roblox simply refuse to load animations. It could help to restart studio.

okay, now try this

local ReplicatedStorage = game:GetService("ReplicatedStorage")
local Players = game:GetService("Players")

local eventClean = ReplicatedStorage:WaitForChild("eventclean")

script.Parnet.Equipped:Connect(function()
    print("Tool has been equipped!")
	warn('Event Called!')
    player = Players.xptmxmgkfj

	local character = player.Character or player.CharacterAdded:Wait()
	local humanoid = character:FindFirstChildOfClass("Humanoid")
	warn('Character =', character, "AND humanoid =", humanoid)

	local animator = humanoid:FindFirstChildOfClass("Animator")

	local tool = script.Parent
	
	if animator then
		warn('Loaded Animator!')
		local anim = Instance.new("Animation")
		anim.AnimationId = "rbxassetid://126407570972225" -- βœ… μ΄λ ‡κ²Œ 고쳐야 함
		local animationTrack = animator:LoadAnimation(anim)
		animationTrack:Play()

		task.delay(3, function()
			if animationTrack then
				animationTrack:Stop()
			end
		end)
	end
end)

The animation works
But how to change?

Wait, when did it work, which script???

Also let’s not do this harder than it have to. Just debug this piece of code instead:

local player = game.Player.LocalPlayer
local character = player.Character or player.CharacterAdded:Wait()
local humanoid = character:WaitForChild("Humanoid")
local animator = humanoid:WaitForChild("Animator")

local anim = Instance.new("Animation")
anim.AnimationId = "rbxassetid://126407570972225"

local track = animator:LoadAnimation(anim)
track:Play()
print("is playing")

The event side didn’t work, only the animation worked.