How to instantly kill an animation without the fading issue [SOLVED]

I need help so basically I’m trying to find a way to instantly kill an animation in Roblox but the problem is adjustWeight(0) and Stop() doesn’t seems to work well here’s lies the server code of my dips animation killer

game.ReplicatedStorage.CharacterAction.Dips:FireClient(player, player)

	CallbackHandler = CurrentPlayer.Humanoid.Changed:Connect(function(property)
		if CurrentPlayer ~= nil and property == 'Jump' then
			print("RIG JUMPED OUT OF BED")
			
			CurrentPlayer.HumanoidRootPart.Weld:Remove()
			--CurrentPlayer.RightHand.Weld:Remove()
			

			local ClonePunch = CurrentPlayer.Punch:Clone()
			CurrentPlayer.Punch:Destroy()

			ClonePunch.Parent = CurrentPlayer
			ClonePunch.Disabled = false
			
			local FollowCamera = CurrentPlayer.FollowCamera:Clone()
			CurrentPlayer.FollowCamera:Destroy()
			FollowCamera.Parent = CurrentPlayer
			FollowCamera.Disabled = false
			
			player.PlayerGui.StatGUI.HealthFrame.ExpCalisthenics.Active = false
			player.PlayerGui.StatGUI.HealthFrame.ExpCalisthenics.Visible = false
			
			ClickDetector.MaxActivationDistance = 15
			game.ReplicatedStorage.UnbindAction.UnbindPullup:FireClient(player, player)

			for i, j in pairs(DipsFolder:GetChildren()) do
				for k, l in pairs(j:GetChildren()) do
					if l.Name == "DipLeft" then
						ShowClickDetector:FireClient(player, l.ClickDetector, 15)
					end
				end

			end
			
			LeaveDips(player.Character)
			
			local CloneDips = CurrentPlayer.Dips:Clone()
			CloneDips.Parent = CurrentPlayer
			CurrentPlayer.Dips:Destroy()
		end
	end)

Here’s lies all the client code

local UserInput = game:GetService("UserInputService")
local DipsEvent = game.ReplicatedStorage.CharacterAction.Dips

local CanDips = true
local char = script.Parent

local ReplicatedStorage = game.ReplicatedStorage
local event = ReplicatedStorage.Remotes.AddHealth

local ClickCounter = game.ReplicatedStorage.Click.ClickerCounter

local animation = Instance.new("Animation")
animation.AnimationId = "http://www.roblox.com/Asset?ID=15864448315"

local humanoid = char:WaitForChild("Humanoid")
local YourAnimationTrack = humanoid.Animator:LoadAnimation(animation)


DipsEvent.OnClientEvent:Connect(function(currentPlayer)
	UserInput.InputBegan:Connect(function(input)
		if input.UserInputType == Enum.UserInputType.MouseButton1 or (Enum.UserInputType.Touch and UserInput.TouchEnabled) then
			if CanDips == true  then
				CanDips = false

				ClickCounter:FireServer(currentPlayer)
				YourAnimationTrack.Priority = Enum.AnimationPriority.Action2
				YourAnimationTrack:Play()
				wait(YourAnimationTrack.Length)

				CanDips = true
			end	
		end
	end)
end)

game.ReplicatedStorage.UnbindAction.UnbindDips.OnClientEvent:Connect(function(player)
	YourAnimationTrack:AdjustSpeed(0)
	YourAnimationTrack:Stop()
end)

It seems like I applied the same logic on the pull up bar but it doesn’t seems to work on the dips thing

Your help can be greatly appreciated !

1 Like

Try :Stop(0) here. First parameter is fade time!

4 Likes

Already tried that sadly didn’t work I made some research and people said to write this but it didn’t work either

Wait a minute where do you want me to put the Stop(0) ??

Also sadly the problem persist also on pull up

On the animation track you are playing. Change category to #help-and-feedback:scripting-support.

1 Like

this is where you should change

And why should I remove the line that is right here ?

don’t remove the last line try to set the speed to :Speed(0) and see if it solves the issue :slight_smile:

Alright I’ll try that and see what it does

Nope doesn’t solve the issue unfortunately

:Play() has a little hidden param thatll set the animation weight directly, try doing :Play(0) and see if that has any effect

Doesn’t work either I tried replacing AdjustWeight(0) or Stop(0) to Play(0) no success so far

Paste this code where you put your client code (I adjusted some pieces of the code you sent above):

local UserInput = game:GetService("UserInputService")
local DipsEvent = game.ReplicatedStorage.CharacterAction.Dips

local CanDips = true
local char = script.Parent

local ReplicatedStorage = game.ReplicatedStorage
local event = ReplicatedStorage.Remotes.AddHealth

local ClickCounter = game.ReplicatedStorage.Click.ClickerCounter

local animation = Instance.new("Animation")
animation.AnimationId = "http://www.roblox.com/Asset?ID=15864448315"

local humanoid = char:WaitForChild("Humanoid")
local YourAnimationTrack = humanoid:LoadAnimation(animation)


DipsEvent.OnClientEvent:Connect(function(currentPlayer)
	UserInput.InputBegan:Connect(function(input)
		if input.UserInputType == Enum.UserInputType.MouseButton1 or (Enum.UserInputType.Touch and UserInput.TouchEnabled) then
			if CanDips == true  then
				CanDips = false

				ClickCounter:FireServer(currentPlayer)
				YourAnimationTrack.Priority = Enum.AnimationPriority.Action2
				YourAnimationTrack:Play(0)
				wait(YourAnimationTrack.Length)

				CanDips = true
			end	
		end
	end)
end)

game.ReplicatedStorage.UnbindAction.UnbindDips.OnClientEvent:Connect(function(player)
	YourAnimationTrack:Stop(0)
end)

Let me know if there are any errors and if this fixes the problem

Still experimenting the same issue

What is happening specifically? Putting :Stop(0) should theoretically stop the animation as fast as possible.

1 Like

Animation is still playing until the end once I leave the dips it seems like AnimationTrack is stored in the cache which make it play until the end even tho the animation must have been stopped way long ago

You can attempt to delete the animation instance altogether and then re-create it when you need it.
image

1 Like

I need to destroy the AnimationTrack though ??

1 Like

Yes, I know.
How about you try setting the TimePosition of the YourAnimationTrack to 0 before attempting to stop it and set it’s weight.