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

Making my character go back to original position after animation?

Asked by 5 years ago

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

Log in to vote
1
Answered by
valchip 789 Moderation Voter
5 years ago

You can use :LoadCharacter, here is an article in wiki http://wiki.roblox.com/index.php?title=API:Class/Player/LoadCharacter.

0
I think he means stop animations and go to his other animation. TangoSen 22 — 5y
Ad
Log in to vote
0
Answered by 5 years ago

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

Answer this question