I just did that and now I am getting the error
Play is not a valid member of Animation “Animation” - Client - LocalScript:28
Stack Begin - Studio
Script ‘Players.Froyo1002YT.Backpack.Pistol.LocalScript’, Line 28
here’s my code.
-- LocalScript under the tool:
-- Animation playing
local anim = Instance.new("Animation")
anim.AnimationId = "rbxassetid://12088152379" -- id here
anim.Name = 'Anim'
anim.Parent = script.Parent
local char = game.Players.LocalPlayer.Character or game.Players.LocalPlayer.CharacterAdded:Wait()
local load = char:WaitForChild("Humanoid"):LoadAnimation(anim)
script.Parent.Equipped:Connect(function()
anim:Play()
end)
script.Parent.Unequipped:Connect(function()
anim:Stop()
end)
-- Connecting Motor6D locally
local anim2 = Instance.new("Animation")
anim2.AnimationId = "rbxassetid://12088152379" -- id here
anim.Parent = script.Parent
local char = game.Players.LocalPlayer.Character or game.Players.LocalPlayer.CharacterAdded:Wait()
local load = char:WaitForChild("Humanoid"):LoadAnimation(anim)
script.Parent.Equipped:Connect(function()
anim2:Play()
end)
script.Parent.Unequipped:Connect(function()
anim2:Stop()
end)
--12088152379
When you load an animation using humanoid, it returns a object which you can call play on. You dont call play on the animation object when you load it, you have to use the one the humanoid:LoadAnimation() returned
Meaning instead of doing anim2:Play() or anim:Play(), you would call load:Play(). Also recommend you to name the loaded animations from humanoid:LoadAnimation to something then load