Changing default animation has a delay

  1. What do you want to achieve? Change the player’s default idle animation when equipping a tool.

  2. What is the issue? When switching roblox’s base idle animation through a script, there is a slight delay before the animation actually plays. If you only change the ID, it only plays when you move your character, and through deleting the animation and adding a new one, it plays on it’s own, but only after a second. https://gyazo.com/3ef4eb9f37534cdcef91f9de3ddeb3ec

  3. What solutions have you tried so far? I have tried doing it both on a server and local script, however the problem stays either way. I don’t believe it’s a problem with roblox loading the animation slowly, since the problem persists even after loading the first few times.

This is especially frustrating, as I would like to add a custom idle and walk animation to a tool, but using the Animate script is the only way I can think to add custom animations.

local tool = script.Parent
local player = game.Players.LocalPlayer
local chr = player.Character
local event = game.ReplicatedStorage.WeaponOut
local w_o = chr.WeaponOut
local idle = game.ReplicatedStorage.idle
local walk = game.ReplicatedStorage.walk
local walkanims = {
	["Fists"] = "http://www.roblox.com/asset/?id=12432482581"; 
}
local idleanims = {
	["Fists"] = "http://www.roblox.com/asset/?id=12432485112"; 
}

local baseidle = "http://www.roblox.com/asset/?id=180435571"
local basewalk = "http://www.roblox.com/asset/?id=180426354"
local animate = player.Character:FindFirstChild("Animate")
local style = player:FindFirstChild("Equipped")["Weapon"]:GetChildren()[1].ItemStyle.Value
tool:GetPropertyChangedSignal("Parent"):Connect(function()
	print("fired")
	if tool.Parent == player.Character then
		print("equipped")
		event:FireServer(true, tool.Name)
		if tool:FindFirstChild("EquipAnimation") then
			local anim = chr.Humanoid.Animator:LoadAnimation(tool.EquipAnimation)
			anim:Play()
		end
		if idleanims[style] then
			animate.idle:Destroy()
			local idleanim = idle:Clone()
			idleanim.Parent = animate
			idleanim.IdleAnim.AnimationId = idleanims[style]
		end
		if walkanims[style] then
			animate.walk:Destroy()
			local runanim = walk:Clone()
			runanim.Parent = animate
			runanim.WalkAnim.AnimationId = walkanims[style]
		end

	end
	if tool.Parent == player.Backpack then
		print("unequipped")
		event:FireServer(false, tool.Name)
		if idleanims[style] then
			animate.idle:Destroy()
			local idleanim = idle:Clone()
			idleanim.Parent = animate
			idleanim.IdleAnim.AnimationId = baseidle
		end
		if walkanims[style] then
			animate.walk:Destroy()
			local runanim = walk:Clone()
			runanim.Parent = animate
			runanim.WalkAnim.AnimationId = basewalk
		end
	end
end)

I attempted to cover up the issue through the use of a tool equip animation, but it would need to be a second or longer which I feel is unnecessary and I would rather just fix the issue.

2 Likes

“maybe” u disable the animate and when the idle and the running animation is imported u set it back again, just asking

1 Like

You can change animations ID directly inside your default Animate local script like this:
Also, to fix this “bug”, you can load the animation by yourself using the Humanoid Running function to check if you need to load the idle or walk/run anim, so it instantly change without delay.

Copy/paste the code in the default “Animate” local script, next to the anim table (line 107).

local Running = false

Character.ChildAdded:Connect(function(Tool)
	if Tool:IsA("Tool") and Tool.Name == "ToolName" then
		local NewAnim = Instance.new("Animation")
		script.idle.Animation1.AnimationId = "http://www.roblox.com/asset/?id=12432485112"
		script.idle.Animation2.AnimationId = "http://www.roblox.com/asset/?id=12432485112"
		script.run.RunAnim.AnimationId = "http://www.roblox.com/asset/?id=12432482581"
		
		if Running == false then
			NewAnim.AnimationId = "http://www.roblox.com/asset/?id=12432485112"
		elseif Running == true then
			NewAnim.AnimationId = "http://www.roblox.com/asset/?id=12432482581"
		end
		
		local NewTrack = Humanoid:LoadAnimation(NewAnim)
		NewTrack.Priority = Enum.AnimationPriority.Action4
		NewTrack:Play()
	end
end)

Humanoid.Running:Connect(function(Speed)
	if Speed > 0 then
		Running = true
	else
		Running = false
	end
end)
1 Like

Load the animation first in the script, not in the equipped function. This way it’s already loaded in the script and you don’t have to reload it each time you equip an item.

1 Like

The script is intended to be able to load a variety of animations based on what weapon you’re using. Also, the walk animation works fine; it loads instantly, but the idle only loads after about a second of being changed.

1 Like

I fixed the issue by making a folder which contains all the idle and walk animations, and then parenting those to the animation script instead of making new animations.

3 Likes

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