Animation won't stop playing

Iam making a pickup and drop system

I got everything done except the animation part. I just want the animation to play inside one function and stop playing in the other function

The issue is that i can play the animation when one function is fired but can’t stop it when the other function is fired

I’ve search everywhere but can’t seem to find how to fix this issue.

I personally think the fix is that i have to find a way to store the animation data in something then try and take that data with me to the other function. Iam probably wrong but i just wanted to share my theory or whatever.

The Code is in a server script

local function PickUp(player)
	
	local idleanimation = script.IdleAnim
	local animator = player.Character.Humanoid:FindFirstChildOfClass("Animator")
	local animationTrack = animator:LoadAnimation(idleanimation)
	animationTrack:Play()
end

local function DropBox(player)
	-- Something here maybe
	animationTrack:Stop()

end

Anything helps :grinning:

,P0TAT0RED

1 Like

is this
local function DropBox(player) even being activated?

for example
DropBox()

I think the problem is the animation track is local so other functions outside its scope can’t access its info. I think something similar to

local function PickUp(player)
	 idleanimation = script.IdleAnim
	local animator = player.Character.Humanoid:FindFirstChildOfClass("Animator")
	 animationTrack = animator:LoadAnimation(idleanimation)
	animationTrack:Play()
end

local function DropBox(player)
	-- Something here maybe
	animationTrack:Stop()

end

might work!

2 Likes

that makes sense lol, almost forgot about that

Thanks man,

Got it to work with your help!

1 Like