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
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
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)