-
What do you want to achieve? Change the player’s default idle animation when equipping a tool.
-
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
-
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.