I have a tool system where if the player uses a tool (in this case a Knife), it gives Swing. It also plays animations. I haven’t been able to find a solution to this problem, and I even tried changing the script from server-sided to client-sided. Both versions are below.
LocalScript:
local details = script.Parent.Details
local debounce = false
local tool = script.Parent
local plr = game.Players.LocalPlayer
local character = plr.Character or plr.CharacterAdded:Wait()
local anim1 = tool.Animations:WaitForChild("LiftAnim")
local animtrack1 = character:WaitForChild("Humanoid"):LoadAnimation(anim1)
local anim2 = tool.Animations:WaitForChild("IdleAnim")
local animtrack2 = character:WaitForChild("Humanoid"):LoadAnimation(anim2)
tool.Activated:Connect(function()
if not debounce then
debounce = true
animtrack1:Play()
print("Anim: Played")
plr.leaderstats.Swing.Value = plr.leaderstats.Swing.Value + details.SwingAmt.Value
plr.LevelStats.XP.Value = plr.LevelStats.XP.Value + details.XPAmt.Value
print("Gave Swing")
wait(details.Cooldown.Value)
debounce = false
end
end)
tool.Equipped:Connect(function()
animtrack2:Play()
end)
tool.Unequipped:Connect(function()
animtrack2:Stop()
end)
Normal Script:
local details = script.Parent.Details
local debounce = false
local tool = script.Parent
repeat wait() until tool.Parent.Parent:IsA("Player")
local plr = tool.Parent.Parent
local character = plr.Character or plr.CharacterAdded:Wait()
local anim1 = tool.Animations:WaitForChild("LiftAnim")
local animtrack1 = character:WaitForChild("Humanoid").Animator:LoadAnimation(anim1)
local anim2 = tool.Animations:WaitForChild("IdleAnim")
local animtrack2 = character:WaitForChild("Humanoid").Animator:LoadAnimation(anim2)
tool.Activated:Connect(function()
if not debounce then
debounce = true
animtrack1:Play()
plr.leaderstats.Swing.Value = plr.leaderstats.Swing.Value + details.SwingAmt.Value
plr.LevelStats.XP.Value = plr.LevelStats.XP.Value + details.XPAmt.Value
wait(details.Cooldown.Value)
debounce = false
end
end)
tool.Equipped:Connect(function()
animtrack2:Play()
end)
tool.Unequipped:Connect(function()
animtrack2:Stop()
end)
I tested both tools and both work as intended, the animation just doesn’t play. I made the animation myself and uploaded it to my group, where the game is also published. The game is private but I don’t think that should affect the animation.
Hello ! Humanoid:LoadAnimation() is outdated and might result in error . Instead, you should do Humanoid.Animator: LoadAnimation() . Also, if you play animation on a local script, it automatically get replicated to other clients . Hope this works. If it doesn’t, any chance you can tell us if the text get printed? what priority is the animation you made?
I have that inside the server-based system (just a normal script in the tool) and it still doesn’t work. I do have this error though for every Item which is currently in my backpack:
Only thing is, the ID of my animation is different. The ID is: 16630556492
Other things:
The script works, but the animation doesn’t and it doesn’t print anything (I added a print(“Animation played”) whilst doing more tests.
The script is from another game (the same game but this is published separately since it’s for testing), and the animation (old animation not the new one I made) also works on that.
Try printing something inside the functions to make sure they are firing. Also, make sure the Animation Priority is set to something high (usually Action). You can do it in the Animation Editor or through a script:
Just curious. Are you the group owner?
I has same problem designing an animation for someone. Uploaded to their group and had Sanitation problems. Sent animation to Group owner to upload himself and walla, it worked…
hmm. Ngl , I recommand client side animation as it appears to be smoother(less laggy) for the player . However, when using client side animation, you got to use Humanoid.Animator:LoadAnimation(AnimationOBj) so that it will not throw an error .
Also, you need to be owner of the group for it to work in games in your group
I’ve been getting this error on a previous animation I had, I don’t use it anymore since I made a new one but it’s still in the game whilst I work on getting this new animation fixed. But to answer your question, yeah I’ve tried that multiple times and I tried looking for other solutions but I can’t find anything.