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

When character resets weapon animations stop working?

Asked by 5 years ago

I noticed that after resetting you player weapon animations stop working. Not sure if I have to have a script to where the localscript in the tool resets itself so that way the weapon animations start working again.

Here is the script for the tool (I know I posted this script in the last post but just going to post it here updated and so that way I can have help)

local plr = game:GetService("Players").LocalPlayer
local char = plr.Character or plr.CharacterAdded:Wait()
local h = char:WaitForChild("Humanoid")
local anim = h:LoadAnimation(script.Parent:WaitForChild("Animation"))

local tool = script.Parent

tool.Equipped:Connect(function()
    anim:Play()
end)

tool.Unequipped:Connect(function()
    anim:Stop()
end)
0
any output? Gameplayer365247v2 1055 — 5y
0
It's just a lot of stack ends Screaming_Monkeys 4 — 5y

1 answer

Log in to vote
0
Answered by 5 years ago
Edited 5 years ago
game.Players.PlayerAdded:Connect(function(plr)
    plr.CharacterAdded:Connect(function(char)
        local h = char:WaitForChild("Humanoid")
        local anim = h:LoadAnimation(script.Parent:WaitForChild("Animation"))

        local tool = script.Parent
        tool.Equipped:Connect(function()
            anim:Play()
        end)

        tool.Unequipped:Connect(function()
            anim:Stop()
        end)
    end
end

My solution its just reload the script everytime the character gets reloaded.

Ad

Answer this question