#Gun Animation
1 messages · Page 1 of 1 (latest)
Define idle_track outside
how
tool.Unequipped:Connect(function()
local idle_anim = tool:WaitForChild("Animations"):WaitForChild("Idle")
local idle_track = tool.Parent:WaitForChild("Humanoid"):GetPlayingAnimationTracks()[idle_anim]
idle_track:Stop()
end)
Outside the event
U can acess it twice
Its not working cuz ur loading a different animation
Here
its the same anim
Its not it doesnt recognize it ```lua
local idle_track = ...
tool.equipped:connect
idle_track:play
tool.unequipped:connect
idle_track:stop
Like on the task scheduler its like different i think
It cant get the same one
it’s because you’re loading the animation twice
they count as separate animations because they’re both different instances of the same animation track
if that makes sense
basically when you load an animation you should use the same global variable for the :Start() and :Stop()
ohh
not two different local variables
let me know
i dont get it
local idle_track = tool.Parent:WaitForChild("Humanoid"):LoadAnimation(idle_anim)
Replace it with that
Like the same animtrack is available twice
To the events
tool.Equipped:Connect(function()
local idle_anim = tool:WaitForChild("Animations"):WaitForChild("Idle")
local idle_track = tool.Parent:WaitForChild("Humanoid"):LoadAnimation(idle_anim)
idle_track:Play()
end)
tool.Unequipped:Connect(function()
local idle_anim = tool:WaitForChild("Animations"):WaitForChild("Unquip")
local idle_track = tool.Parent:WaitForChild("Humanoid"):LoadAnimation(idle_anim)
idle_track:Stop()
end)
solved or nah?
local idle_anim = tool:WaitForChild("Animations"):WaitForChild("Idle")
local idle_track = tool.Parent:WaitForChild("Humanoid"):LoadAnimation(idle_anim)
tool.Equipped:Connect(function()
idle_track:Play()
end)
tool.Unequipped:Connect(function()
idle_track:Stop()
end)
This is correct
i have another problem
why is local showing as an error
is this a module script
server
show more of the script
kk
specifically whats above the function
yup
its just local player =
its not working for some reason
anything in output?
local idle_anim = tool:WaitForChild("Animations"):WaitForChild("Idle")
local idle_track = tool.Parent.Parent:WaitForChild("Humanoid"):LoadAnimation(idle_anim)
tool.Equipped:Connect(function()
idle_track:Play()
end)
tool.Unequipped:Connect(function()
idle_track:Stop()
end)
still doesnt work
this worked but the unequip didnt

holon
local idle_anim = tool:WaitForChild("Animations"):WaitForChild("Idle")
local idle_track = game.Players.LocalPlayer.Character:WaitForChild("Humanoid"):LoadAnimation(idle_anim)
tool.Equipped:Connect(function()
idle_track:Play()
end)
tool.Unequipped:Connect(function()
idle_track:Stop()
end)
this gave me the infinite yield error
this isnt giving me anything
and it doesnt work right
that’s not an error
only warning
because you don’t set a timeout parameter in your WaitForChild
it’s normal
can you help me again
i rewrote the script
the equip works
unequip doesnt
its the same problem u had earlier
local idle_anim = tool:WaitForChild("Animations"):WaitForChild("Idle")
local idle_track = tool.Parent:WaitForChild("Humanoid"):LoadAnimation(idle_anim)
tool.Equipped:Connect(function()
idle_track:Play()
end)
tool.Unequipped:Connect(function()
idle_track:Stop()
end)
** You are now Level 15! **
try this u can remove the functions
i just got back to scripting
i havent scripted since early 2025
cant really remove the equipped function
that’s a few months tops and won’t impact you at all for more than a day but sure wtv
just load an animation outside the equip functions and play it in equip and stop it in unequip
i know why this isnt working
the same problem happened with my ammo gui
if that doesn’t work check if it’s in GetPlayingAnimationTracks
wtf
no the character model is in workspace the player is in Players
when a tool is equipped it’s replicated into the CharacterModel
so why did my ammoUI work when i did tool.parent.parent instead of tool.parent
also
when i did tool.parent on both, it warns me "infinite yield on backpack for humanoid"
so tool.parent is just backpack
okay nvm
** You are now Level 11! **
infinite yield warning only means that the function is yielding indefinitely usually comes from not having a timeout parameter inside WaitForChild
I HAD TO DO tool.parent.parent.character
…
thanks
the ui is in player playergui
yes
so its working
why cant you
oh
