Character stuck in pose after using :Stop()

Hello folks, I’m trying to make a system where your character is in a pose while holding a gun. I managed to make the character in a pose but whenever i try to use animation:Stop() it doesn’t work. I’m unaware of any other method of making the character back to normal so help would be appreciated (The animation is a single frame animation by the way).

script.Parent.hold.OnServerEvent:Connect(function(player,char,gun,tri)
	local humanoid = char:FindFirstChild("Humanoid")
	local anim = script.Parent.Holder
	local holdload = humanoid:LoadAnimation(anim)
	if tri == true then
		holdload:Play()
	else
		holdload:Stop(0.1)
	end
end)

Help would be appreciated.

Do you change the “tri” value to false?

image

Basically when the tool is dequipped, it sends the tri value as false and yes it gets set to false.

This is because you are creating a new animation object, so you’re actually stopping the new animation not the old one that was previously playing. To fix this, try storing the same animation somewhere. (under the character would be good)

1 Like

btw Humanoid:LoadAnimation() is deprecated
use Humanoid.Animator:LoadAnimation()

Remove the 0.1, if it still doesnt work then try using the animator instead

It’s probably because you’re loading a new animation on the character every time the event is fired. You will have lost the previous animation if you try and use this to stop it as well.

Use a local script to load and unload the animation on the player’s character instead and you will be able to save the animation to a variable.

I’m trying to make this used as a tool itself and not for just one game.

I tried and it’s the same result

I tried what you said but now it says:

Holder is not a valid member of Tool "Players.windshield101.Backpack.Ak47"

You are making a new holdload, try use it like here:
Here i define holdload only one time not every time the remote is fired.

repeat wait() until game:IsLoaded()
local humanoid = char:FindFirstChild("Humanoid")
local anim = script.Parent.Holder
local holdload = humanoid:LoadAnimation(anim)
script.Parent.hold.OnServerEvent:Connect(function(player,char,gun,tri)
	if tri == true then
		holdload:Play()
	else
		holdload:Stop(0.1)
	end
end)

This is a server script so that variable will change every time the event is fired and you will only be able to control the latest one.

mmm you can use it:

for i,v in pairs(humanoid:GetPlayingAnimationTracks()) do
    if v.Name == "Holder" then
        v:Stop()
    end
end