#Gun Animation

1 messages · Page 1 of 1 (latest)

stoic fern
#

when i equip the gun, the anim works. but when i unequip it, it doesnt stop the anim

small temple
#

Define idle_track outside

stoic fern
#
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)
small temple
#

Outside the event

#

U can acess it twice

#

Its not working cuz ur loading a different animation

stoic fern
small temple
#

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

lavish fern
#

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()

stoic fern
#

ohh

lavish fern
#

not two different local variables

stoic fern
#

i get it

#

let me try rq

lavish fern
#

let me know

stoic fern
#

doesnt load the animation anymore

small temple
#

LoadAnimation

#

Ur using getplayinganimationtracks

#

Its not an animation track

stoic fern
#

can you like

#

type it

small temple
#

In ur first image

#

Its that line

stoic fern
#

i dont get it

small temple
#

local idle_track = tool.Parent:WaitForChild("Humanoid"):LoadAnimation(idle_anim)

#

Replace it with that

#

Like the same animtrack is available twice

#

To the events

stoic fern
#

i tried

#

doesnt work

small temple
#

Ok so send ur code

#

Gth

#

Gtg

stoic fern
#

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)
plucky ginkgo
#

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)
small temple
#

This is correct

stoic fern
#

why is local showing as an error

plucky ginkgo
#

is this a module script

stoic fern
plucky ginkgo
#

show more of the script

stoic fern
stoic fern
plucky ginkgo
#

specifically whats above the function

stoic fern
#

omg

#

im so dumb

#

this is above it

plucky ginkgo
#

yup

stoic fern
#

its just local player =

stoic fern
plucky ginkgo
#

anything in output?

stoic fern
plucky ginkgo
#
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)
stoic fern
plucky ginkgo
#

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)
stoic fern
plucky ginkgo
#

show the error

#

plz

plucky ginkgo
#

and it doesnt work right

stoic fern
#

yea

#

wtf

#

im not getting anything

#

from both

ionic elm
#

only warning

#

because you don’t set a timeout parameter in your WaitForChild

#

it’s normal

stoic fern
#

im rewriting it

stoic fern
#

i rewrote the script

#

the equip works

#

unequip doesnt

small temple
#

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)
hot eagleBOT
#

studio** You are now Level 15! **studio

small temple
#

try this u can remove the functions

ionic elm
#

how is this guy s2 and im not evilcat

stoic fern
#

i havent scripted since early 2025

stoic fern
ionic elm
#

that’s a few months tops and won’t impact you at all for more than a day but sure wtv

stoic fern
#

omg

#

i get it

#

hold on

ionic elm
#

just load an animation outside the equip functions and play it in equip and stop it in unequip

stoic fern
#

the same problem happened with my ammo gui

ionic elm
#

if that doesn’t work check if it’s in GetPlayingAnimationTracks

stoic fern
#

tool.parent is backpack

#

tool.parent.parent is player

ionic elm
#

wtfcrying

small temple
#

no

#

its in workspace ur player

#

so

ionic elm
#

when a tool is equipped it’s replicated into the CharacterModel

stoic fern
#

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

hot eagleBOT
#

studio** You are now Level 11! **studio

stoic fern
#

wtf

#

YES

#

YES

#

YES

#

I GOT IT WORKING

ionic elm
#

infinite yield warning only means that the function is yielding indefinitely usually comes from not having a timeout parameter inside WaitForChild

stoic fern
#

I HAD TO DO tool.parent.parent.character

ionic elm
#

stoic fern
#

thanks for yalls help

ionic elm
#

whatever floats your boat ig lol

#

gl

stoic fern
#

thanks

small temple
stoic fern
small temple
#

so its working

small temple
stoic fern
#

since its a gun

small temple
#

oh