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

When character resets weapon animations stop working?

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)

2 comments

0

any output?

0

It's just a lot of stack ends

1 answer

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.

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