How do you reset the Animate script without stopping the character?


I’m currently trying to change the default Animate local script animations, however, they do not play instantly after the script has been disabled and re-enabled.

robloxapp-20220727-0310549.wmv (1.7 MB)

I have no idea what to do to fix this and make it so the animation that’s to get replaced, continues to play after the animations have been swapped.

Script

["Animate Script Control"] = {
		Description = "This function will change the Animate IDs to what they need to be.",
		Function = function(Player,WithPuck)
			
			--[[J2T Notes; I attempted disabling the LocalScript, creating a table to replay the animations after they are stopped, removing the stop animation tracks, and stopping the animations on the Client side. None have worked so far.]]
			
			local Character = game.Workspace:WaitForChild(Player.Name)
			if Character and Character:FindFirstChild("Humanoid") and Character:FindFirstChild("Animate") then
				local AnimateScript,Humanoid = Character:FindFirstChild("Animate"),Character:FindFirstChild("Humanoid")
				local animator = Humanoid:WaitForChild("Animator")
				
				for _, track in pairs(animator:GetPlayingAnimationTracks()) do
					track:Stop(0)
				end
				AnimateScript.Disabled = true
				AnimateScript.ScaleDampeningPercent.Value = .4
				if not WithPuck then
					if Character.Humanoid.RigType == Enum.HumanoidRigType.R15 then
						warn("R15 Rig Found!")
					elseif Character.Humanoid.RigType == Enum.HumanoidRigType.R6 then
						warn("R6 Rig Found!")
						AnimateScript.run.RunAnim.AnimationId = "rbxassetid://7759384613"        -- Run
						AnimateScript.walk.WalkAnim.AnimationId = "rbxassetid://7759384613"      -- Walk
						AnimateScript.jump.JumpAnim.AnimationId = "rbxassetid://125750702"      -- Jump
						AnimateScript.idle.Animation1.AnimationId = "rbxassetid://7758334166"    -- Idle (Variation 1)
						AnimateScript.idle.Animation2.AnimationId = "rbxassetid://7758334166"    -- Idle (Variation 2)
						AnimateScript.fall.FallAnim.AnimationId = "rbxassetid://180436148"      -- Fall
						AnimateScript.climb.ClimbAnim.AnimationId = "rbxassetid://180436334"
						AnimateScript.sit.SitAnim.AnimationId = "rbxassetid://0"
						AnimateScript.toolnone.ToolNoneAnim.AnimationId = "rbxassetid://0"
					end
				elseif WithPuck then
					if Character.Humanoid.RigType == Enum.HumanoidRigType.R15 then
						warn("R15 Rig Found!")
					elseif Character.Humanoid.RigType == Enum.HumanoidRigType.R6 then
						warn("R6 Rig Found!")
						AnimateScript.run.RunAnim.AnimationId = "rbxassetid://7759384613"        -- Run
						AnimateScript.walk.WalkAnim.AnimationId = "rbxassetid://8588036860"      -- Walk
						AnimateScript.jump.JumpAnim.AnimationId = "rbxassetid://125750702"      -- Jump
						AnimateScript.idle.Animation1.AnimationId = "rbxassetid://8587855477"    -- Idle (Variation 1)
						AnimateScript.idle.Animation2.AnimationId = "rbxassetid://8587855477"    -- Idle (Variation 2)
						AnimateScript.fall.FallAnim.AnimationId = "rbxassetid://180436148"      -- Fall
						AnimateScript.climb.ClimbAnim.AnimationId = "rbxassetid://180436334"
						AnimateScript.sit.SitAnim.AnimationId = "rbxassetid://0"
						AnimateScript.toolnone.ToolNoneAnim.AnimationId = "rbxassetid://0"
					end
				end
				task.delay(.005,function() 
					AnimateScript.Disabled = false
				end)
			end
		end,
	},

did you name the localscript “Animate” and placed it in StarterCharcterScripts?
that will replace your animatons localscript by the default one.

I’m not replacing the Animate script, I’m changing the values inside the Animate script so I don’t have to replace it. Replacing the Animate script tends to cause bugs, such as all animations breaking.

I suggest you use a custom animate script, since creating a new animate script would bug out the animations if not used properly, or having to awkwardly make the player jump if you want to change the players animations.

I have one here, if you want to use it (Put this on the default Animate script):
for i,v in pairs(script:GetChildren()) do for i,x in pairs(v:GetChildren()) do if x:IsA("Animation") then v.Changed:Connect(function() for i,animation in pairs(script.Parent.Humanoid:GetPlayingAnimationTracks()) do animation:Stop() end end) end end end