Help needed in script

Im Working on a training simulator and this is a lift script when the player presses LMB plays animation but it doesn’t work, here is the script:

plr = game.Players.PlayerAdded:Wait()
char = plr.CharacterAdded:Wait()
liftanim = script.LiftAnim
tool = script.Parent

if tool.Parent == plr.Backpack then
    local mse = plr:GetMouse()
    tool.Equipped:Connect(function(mouse)
          if mouse.Button1Down then
               local anim = char.Humanoid:LoadAnimation(liftanim)
               anim:Play()
        end
     end)
end

literally just do

tool.Activated:Connect(function ()
-- stuff here
end)

you dont have to do all that, tool can only be activated when equipped anyway, so it doesnt matter. But, the reason why it isnt working because its not connected to an event, so its technically just checking if the mouse is currently down when equipped. Not activating whenever the mouse is clicked

no but the problem is the animation doesn’t play

yeah and thats because its not getting triggered

and how to do so?

13131313131313 ignore

as i said ontop, just link the animation to the tool activated event

i did tho but still doesn’t work

I’d just do what Quvel said to. Also if it’s a local script I’d change

plr = game.Players.PlayerAdded:Wait()

to

plr = game.Players.LocalPlayer

can i see the code? 133123123123

Also, char.Humanoid:LoadAnimation is a bad habit. Use the Animator instance inside of the humanoid instead.

plr = plr = game.Players.LocalPlayer
char = plr.CharacterAdded:Wait()
liftanim = script.LiftAnim
tool = script.Parent

wait(0.2)

tool.Activated:Connect(function ()
	local mse = plr:GetMouse()
	tool.Equipped:Connect(function(mouse)
		if mouse.Button1Down then
			local anim = char.Humanoid:LoadAnimation(liftanim)
			liftanim:Play()
		end
	end)

end)

?? you dont need any of the events (equipped and if mouse.Button1Donw), just do the local anim stuff, and play the anim not the liftanim

also, use local on variables so you save more on memory

Try this:

local plr = game:GetService("Players").LocalPlayer
local char = plr.Character or plr.CharacterAdded:Wait()
local liftanim = script.LiftAnim
local tool = script.Parent

tool.Activated:Connect(function()
	local anim = char.Humanoid.Animator:LoadAnimation(liftanim)
	anim:Play()
end)

doesn’t play any animation doesn’t work no errors no nothing

Could you show the hierarchy of the tool?

what? 1313331313131313111111414141

It probably doesn’t have a handle and requires handle is true

it does have one 2121212121212121212

Where’s the tool located, and is the script a local script?