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

Animation script broken?

Asked by 7 years ago

Okay, I asked a question about a local script earlier that did not play an animation.

I tried to also get the local script to play an animation on equipped/unequipped. I changed where I put the animation variables and now none of the animations play. What is wrong?

-- Local Script in tool
local plr = game.Players.LocalPlayer
local char = plr.Character or plr.CharacterAdded:wait()
local humanoid = char:WaitForChild("Humanoid")
local tool = script.Parent
local handle = tool:WaitForChild("Handle")
local swinganim = handle:WaitForChild("swinganim")
local heldanim = handle:WaitForChild("heldanim")
local playAnim1 = humanoid:LoadAnimation(swinganim)
local playAnim2 = humanoid:LoadAnimation(heldanim)

function swing()
    tool.GripForward = Vector3.new(-0.546, -0, 0.838)
    tool.GripPos = Vector3.new(0.292, -0.037, -2.099)
    tool.GripRight = Vector3.new(0.838, -0, 0.546)
    tool.GripUp = Vector3.new(-0, -1, -0)
    playAnim1:Play()
    wait(2)
    playAnim1:Stop() 
    tool.GripForward = Vector3.new(1, -0.024, -0)
    tool.GripPos = Vector3.new(-0.2, -0.114, -0.164)
    tool.GripRight = Vector3.new(-0.024, -1, -0)
    tool.GripUp = Vector3.new(0, -0, 1)
end

function equipped()
    tool.GripForward = 1, -0.024, -0
    tool.GripPos = -0.2, -0.114, -0.164
    tool.GripRight = -0.024, -1, -0
    tool.GripUp = 0, -0, 1
    local playAnim = humanoid:LoadAnimation(heldanim)
    playAnim2:Play()
end

function unequipped()
    playAnim2:Stop()
end


tool.Equipped:connect(equipped)
tool.Unequipped:connect(unequipped)
tool.Activated:connect(swing)

Answer this question