Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

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

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?

7 comments

0

Is it a roblox character or custom character

0

The `layer

0

Is the script inside a tool

0

yes

0

look at answer and try that.

0

It works, but when I unequip the tool the animation continues running

0

try now

1 answer

✓ Accepted answer
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)

2 comments

0

It works, but when I unequip the tool the animation continues running

0

Yes, now it works

This discussion is preserved as it was. New answers, comments, and votes are closed.