Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

How do I put an animation in a sword when I'm not moving? (idle animation)

Asked by 6 years ago
Edited 6 years ago

I want to make a sword with an idle animation. I tried with this:


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

moving=false Humanoid.Running:connect(function(value) if value>0 then moving=true else moving=false end)

while wait() do if not moving then end end

How do I do It?

0
Is it a roblox character or custom character 522049 152 — 6y
0
The `layer FrikiGameplaysHD 1 — 6y
0
Is the script inside a tool 522049 152 — 6y
0
yes FrikiGameplaysHD 1 — 6y
View all comments (3 more)
0
look at answer and try that. 522049 152 — 6y
0
It works, but when I unequip the tool the animation continues running FrikiGameplaysHD 1 — 6y
0
try now 522049 152 — 6y

1 answer

Log in to vote
0
Answered by
522049 152
6 years ago
Edited 6 years ago
tool = script.Parent
tool.Equipped:Connect(function()
    if not tool.Parent:isA("Backpack") then
        local char = tool.Parent
        local humanoid = char:FindFirstChild("Humanoid")
        local animate = char:FindFirstChild("Animate")
        if humanoid and animate and animate:FindFirstChild("idle") then
            local idle1 = animate.idle:WaitForChild("Animation1")
            local idle2 = animate.idle:WaitForChild("Animation2")
            local default1 = idle1.AnimationId
            local default2 = idle2.AnimationId
            idle1.AnimationId = "http://www.roblox.com/Asset?ID=1776614601"
            idle2.AnimationId = "http://www.roblox.com/Asset?ID=1776614601"
            tool.Unequipped:Connect(function()
                local ActiveTracks = humanoid:GetPlayingAnimationTracks()
                for _,v in pairs(ActiveTracks) do
                    v:Stop()
                end
                idle1.AnimationId = default1
                idle2.AnimationId = default2
            end)

        end
    end
end)
0
It works, but when I unequip the tool the animation continues running FrikiGameplaysHD 1 — 6y
0
Yes, now it works FrikiGameplaysHD 1 — 6y
Ad

Answer this question