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

How Do I Make Looping Animation Tools In Your Back Pack?

I want to add a tool in the games backpack where it plays the animation when clicked and stops when clicked again. Kinda like the ones in do your homework simulator. I've been trying to find tutorials for it but I cant find any that help.

1 answer

Ok so I have something in mind. Insert this Script and a Part named Handle into your tool. Make the handle's transparency 1.

wait(0.5)
local animation = Instance.new("Animation", script.Parent)
animation.AnimationId = "rbxassetid://0000000000" --insert your anim id
local unequipped = true

function Activated()
    if unequipped == true then
        repeat
            loadAnim = script.Parent.Parent.Humanoid:LoadAnimation(script.Parent.Animation)
            loadAnim:Play()
            unequipped = false
            wait(1.5) -- insert animation length
        until unequipped == true
    else
		unequipped = true
		loadAnim:Stop()
		loadAnim:Destroy()
    end
end

function Unequip()
    unequipped = true
	loadAnim:Stop()
	loadAnim:Destroy()
end

script.Parent.Activated:Connect(Activated)
script.Parent.Unequipped:Connect(Unequip)

Also if you are in Animation Editor you can press a button and it will make it loop. But this works too. Check out this place here if you want to test it out.

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