So I have a sword that has multiple attack animations and a Idle animation when you enable it, but for some reason the idle animation doesnt work (I remember a few months ago it did), heres the script:
local Tool = nil local animScript = nil script.Parent.Equipped:Connect(function() Tool = script.Parent animScript = Tool.Parent:WaitForChild("Animate") animScript:WaitForChild("toolnone"):WaitForChild("ToolNoneAnim") animScript.toolnone.ToolNoneAnim.AnimationId = "https://roblox.com/asset/?id=5341725784" end) script.Parent.Equipped:Connect(function() Tool = script.Parent animScript:WaitForChild("toolnone"):WaitForChild("ToolNoneAnim") animScript.toolnone.ToolNoneAnim.AnimationId = "https://roblox.com/asset/?id=5341725784" end)
You have to load in the animation inside the humanoid for it to work. Since this is probably a local script you first define the humanoid.
local Tool = nil local animScript = nil local humanoid = script.Parent.Parent:FindFirstChild("Humanoid") --The humanoid is defined like this because since the tool is equipped, it will on your char. script.Parent.Equipped:Connect(function() Tool = script.Parent animScript = Tool.Parent:WaitForChild("Animate") animScript:WaitForChild("toolnone"):WaitForChild("ToolNoneAnim") local animation = humanoid:LoadAnimation( animScript.toolnone.ToolNoneAnim) animation:Play() end)
Also, it seems like you may have duplicated your equipped event, since the animationID is the exact same.
OK i have been through this problem before, all u need to do is
local Tool = script.Parent local player = game:GetService('Players').LocalPlayer local character = player.Character or player.CharacterAdded:Wait() local humanoid = character:WaitForChild('Humanoid') Idle = Instance.new("Animation") Idle.AnimationId = "http://www.roblox.com/asset/?id=5882776048" Tool.Equipped:Connect(function() idleanim = player.Character.Humanoid:LoadAnimation(Idle) idleanim:Play() end) Tool.Unequipped:Connect(function() idleanim = player.Character.Humanoid:LoadAnimation(Idle) idleanim:Stop() end)