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

Making my character go back to original position after animation?

I tried this script, but when I unequip the sword, it stays on the position it was when the animation ended

local tool = script.Parent -- use local variables
local Player = game.Players.LocalPlayer --get the local player
local isitEquipped = Player.hasWeapon

tool.Equipped:Connect(function(mouse) -- :Connect not :connect, :connect is deprecated
	isitEquipped.Value = true
	local attack = tool.Parent.Humanoid:LoadAnimation(script.equipAnimation) -- script.Parent is tool so just use tool.Parent
	attack:Play()
	wait(attack.Length - 0.1)
	attack:AdjustSpeed(0)
end)

tool.Unequipped:connect(function()
	isitEquipped.Value = false
	local getName = script.Parent.Parent.Parent.Name
	local attack = workspace:FindFirstChild(getName).Humanoid:LoadAnimation(script.equipAnimation)
	local idle = workspace:FindFirstChild(getName).Humanoid:LoadAnimation(script.Idle)
	attack:AdjustSpeed(1)
	wait(0.1)
	attack:AdjustSpeed(1)
	attack:Stop()
end)

How do I make it go back to the position it was before the animation?

2 answers

What you are going to when to loop through the playing animations tracks and stop them.

local Humanoid = Player.Character.Humanoid
local ActiveTracks = Humanoid:GetPlayingAnimationTracks()
for _,v in pairs(ActiveTracks) do
    v:Stop()
end

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