Animation not stop playing

howdy fellow developers, i have a bug where the animation is not stopping after it reached to the point

example of this video:(idk if the video plays on you)

any idea how to fix this

also the animation were on the server-sided

local rightArm = charTouched["Right Arm"]
local wc = Instance.new("Motor6D")
wc.Part0 = rightArm
wc.Part1 = flagOnBack.PrimaryPart
wc.Parent = rightArm
if charTouched:WaitForChild("Humanoid") then
   charTouched:WaitForChild("Humanoid").WalkSpeed += 8
end
flagrunAnim:Play()

flagOnBack.Name = "FLAG"
flagOnBack.Parent = charTouched

for i, desc in pairs(team1Flag.FlagModel:GetDescendants()) do
   if desc:IsA("BasePart") then
	    desc.Transparency = 1
		desc.CanCollide = false
	end
end

charTouched.Humanoid.Died:Wait()
if flag1Taken == charTouched then
	disableBackpackEvent:FireClient(plrTouched, true)
	flag1Taken = false
	for i, desc in pairs(team1Flag.FlagModel:GetDescendants()) do
		if desc:IsA("BasePart") then
			desc.Transparency = 0
		end
	end
end
elseif flag2Taken == charTouched and charTouched.Humanoid.Health > 0  and plrTouched.Team == team1 then
	disableBackpackEvent:FireClient(plrTouched, true)
	flag2Taken = false
	charTouched["FLAG"]:Destroy()
	team1Score.Value += 1
	flagrunAnim:Stop() --something wrong here
	for i, desc in pairs(team2Flag.FlagModel:GetDescendants()) do
		if desc:IsA("BasePart") then
			desc.Transparency = 0
			desc.CanCollide = false
		end
	end
	if charTouched:WaitForChild("Humanoid") then
		charTouched:WaitForChild("Humanoid").WalkSpeed -= 8
	end
end

:Stop() is not a function, you have to set the animation speed to 0. If I remember correctly, the function is called :SetSpeed().

Edit: it might be :AdjustSpeed()

then the animation will be freezed instead of stopping

I’m not completely sure what you are trying to do with the animation but you could adjust it’s time position to 0 if you want it to restart.

Edit: I just watched the video and I understand now. Maybe destroy the animation after it stops. You could also disable looping on the animation and let the animation stop by itself.

i finally figured it out how i stop the animation

turns out you need to make a variable as a objectvalue like

local animation

if not animation then
   animation = character.Humanoid:LoadAnimation(yourAnimation)
end
animation:Play()
if animation then
   animation:Stop()
end

thanks for trying to help mate

1 Like

I didn’t even realize that you could use :Stop() on an animation, I thought you had to set the speed to 0. Sorry for accidentally giving you false information lol.

1 Like

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.