I’ve been developing my game for a few weeks, and one thing I’ve been looking forward to the absolute most is the tools, but more so the tool animations!
The problem is, whenever I test the tool’s animation, it doesn’t seem to work! The script doesn’t error, and everything is correctly written (I believe), so if anyone knows the issue, please let me know!
Code:
local Anim = script.Parent.IK_ANIM
local Player = game.Players.LocalPlayer
script.Parent.Activated:Connect(function()
local Humanoid = Player.Character:FindFirstChildOfClass('Humanoid')
local Animation = Humanoid:LoadAnimation(Anim)
Animation:Play()
end)
This is a LocalScript under the tool! (I originally set it as a script and got the player another way, but that script didn’t work, so I changed it to a LocalScript, and changed the way of getting the player, which obviously didn’t work-)
Try and test the animation normally without it being activated by a tool, also for more bug testing add prints between every line and see if they print
I just doubled checked and I think you can load animations on the client, though this has been buggy for me in the past. Though I would stick to a local script since that’s what I’ve been using in my recent game.
local Anim = script.Parent:WaitForChild("IK_ANIM")
local Player = game.Players.LocalPlayer
script.Parent.Activated:Connect(function()
local Character = Player.Character or Player.CharacterAdded:Wait()
local Humanoid = Character:FindFirstChildOfClass('Humanoid')
local Animation = Humanoid:LoadAnimation(Anim)
Animation:Play()
end)
local Anim = script.Parent:WaitForChild("IK_ANIM")
local Tool = script.Parent
Tool.Activated:Connect(function()
local Character = Tool.Parent
local Humanoid = Character:WaitForChild('Humanoid')
local Animation = Humanoid:LoadAnimation(Anim)
Animation:Play()
end)
local PS = game:GetService("Players");
local Anim = script.Parent:WaitForChild("IK_ANIM");
local Player = PS.LocalPlayer;
local Character = Player.Character or Player.CharacterAdded:Wait();
local Humanoid = Character:FindFirstChildOfClass("Humanoid");
local Animator = Humanoid:FindFirstChildOfClass("Animator");
script.Parent.Activated:Connect(function()
if Humanoid and Animator then
local Animation = Animator:LoadAnimation(Anim)
Animation:Play()
end
end)
Animations are recommended to be played through the Animator nowadays, make sure the animation is uploaded to the game’s creators profile, or if it is a group game, upload it to the group.