local Tool = script.Parent
local AnimationsFolder = Tool:FindFirstChild(“Animations”)
local Idle = AnimationsFolder:FindFirstChild(“Idle”)
local Slash = AnimationsFolder:FindFirstChild(“Slash”)
local Diagonal = AnimationsFolder:FindFirstChild(“Diagonal”)
local IdleTrack;
local SlashTrack;
local DiagonalTrack;
function GetPlayer(Character)
local Player = game:GetService(“Players”):GetPlayerFromCharacter(Character)
if Player then
return Player
end
end
Tool.Equipped:Connect(function()
local Player = GetPlayer(Tool.Parent)
if Player then
local Character = Player.Character
if Character then
local Humanoid = Character:FindFirstChild(“Humanoid”)
if Humanoid then
IdleTrack = Humanoid:LoadAnimation(Idle)
IdleTrack:Play()
end
end
end
end)
Tool.Unequipped:Connect(function()
if IdleTrack then
IdleTrack:Stop()
end
end)
Instead of using a script inside of the tool, I would suggest amending the Animate script that a player spawns with.
I would do something like this:
function onRunning(speed)
if speed > 0.75 then
local scale = 16.0
playAnimation("walk", 0.2, Humanoid)
setAnimationSpeed(speed / scale)
pose = "Running"
else
if emoteNames[currentAnim] == nil and not currentlyPlayingEmote and not Character.ToolName then
playAnimation("idle", 0.2, Humanoid)
pose = "Standing"
elseif emoteNames[currentAnim] == nil and not currentlyPlayingEmote and Character.ToolName then
local a = Humanoid:LoadAnimation(Character.ToolName.AnimationsFolder:FindFirstChild("Idle")
a:Play()
end
end
end
In regards to any other animations that may involve multiple animations (such as animation playing when both running and walking), I would use LoadAnimation on a normal script (my method was just for idle animations).
I had a similar issue that started happening late last week. Was not able to reproduce the issue in studio, only when playing on a server.
I have a series of 4 non-looped animations that are loaded when the client spawns. About 5% of the time the animations just silently fail to load.
You can call :Play() on them and nothing happens. I don’t see any script errors but if you query the animation objects later, you’ll see the animation lengths are all zero.
For now I just put in a really hacky loop to load all the animations 5 times on startup, it’s horrible but it fixed the problem for now. This feels like a platform bug, I was planning on checking over my code first before raising it.