Although this code does technically work, I find myself wanting a better way to do this. Are there better ways to go about having custom animations when a tool is equipped, and if so what are they? (I appreciate all help whether it’s related to scripting or not. I have very little experience in the way of animating.)
Currently I use the following script in the tool to do it:
-- Variables --
local plr = game:GetService("Players").LocalPlayer
local tool = script.Parent
local animate = plr.Character.Animate
local animations = tool.Animations
-- Functions --
-- Change to new animations --
tool.Equipped:Connect(function()
animate.idle.Animation1.AnimationId = animations.Idle.AnimationId
animate.idle.Animation2.AnimationId = animations.Idle.AnimationId
animate.walk.WalkAnim.AnimationId = animations.Walk.AnimationId
end)
-- Revert to default animations --
tool.Unequipped:Connect(function()
animate.idle.Animation1.AnimationId = "rbxassetid://180435571"
animate.idle.Animation2.AnimationId = "rbxassetid://180435792"
animate.walk.WalkAnim.AnimationId = "rbxassetid://180426354"
end)
I find that there are several issues with this though, such as delayed animation switching times, it possibly not even being on the server right (probably because this is in a local script, so I can try solving this myself- I haven’t tried yet tbh.), and it would become a hassle to update and add new animations any time I did.
I want the script to also work with other tools as well and all I’d have to do is update the animation IDs according to the tool.
Here is a video of the issues I’m talking about: