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

Help with animations?

local tool = script.Parent
local animation = tool:WaitForChild("Animation")
local animation2 =tool:WaitForChild("Animation2")
local player = game.Players.LocalPlayer

local animationtrack
local buttonpressed = false

tool.Equipped:connect(function()
	local character = player.Character
	local humanoid = character:WaitForChild("Humanoid")
	animationtrack = humanoid:LoadAnimation(animation)
    animationtrack:Play()
end)




	tool.Activated:connect(function()
		if not buttonpressed then
		buttonpressed = true
		local character = player.Character
		local humanoid = character:WaitForChild("Humanoid")
		animationtrack = humanoid:LoadAnimation(animation2)
		animationtrack:Play()
		wait(3)
		buttonpressed = false
		end
	end)



tool.Unequipped:connect(function()
	animationtrack:Stop()
end)

There are a few problems going on here... 1. If I try to unequip the tool while the animation is playing the character doesn't go back into its default position. The character stays in the position of the first animation 2. If I try to unequip the tool after I play the animation once or more, when I unequip the tool, the character again stays in the position of the first animation. :P Please help!

2 answers

The method Stop of the AnimationTrack will make the animation end when you call it. When your tool is unequipped, call this function to end your animation prematurely.

1 comment

0

I already have stop in my script though... help!

Thx but I don't completely understand what you're saying. Do you think you could modify my script and show me what you mean?

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