Animated Tool not working until reset

Hey, I am making a tool system and when a player equips a tool it is supposed to play an animation. But, you have to reset in order for it to work.

local Player = game.Players.LocalPlayer
local on = false
local Character = Player.CharacterAdded:Wait()

script.Parent.Equipped:Connect(function()
	if Character then
	idle = Character:WaitForChild("Humanoid"):LoadAnimation(script.Parent:WaitForChild("Idle"))
		idle:Play()
	end
end)

script.Parent.Unequipped:Connect(function()
	if Character then
		idle:Stop()
	end
end)

Try this:

local Player = game.Players.LocalPlayer
local on = false
local Character = Player.CharacterAdded:Wait()
Animator = Character:WaitForChild("Humanoid"):WaitForChild("Animator")
idle = Animator:LoadAnimation(script.Parent:WaitForChild("Idle"))

script.Parent.Equipped:Connect(function()
    if Character then
        idle:Play()
    end
end)

script.Parent.Unequipped:Connect(function()
    if Character then
        idle:Stop()
    end
end)
2 Likes

Same thing still happens. I have no idea why

Is there something else in the script? And can you send where a screenshot of the Tool? (their descendants)

1 Like

SDEDS

Your Character variable is only checking for a Player.CharacterAdded event, but no Player.Character as well which is possibly why you need to reset for it to work

Try this in relation with @SOTR654’s script:

local Player = game.Players.LocalPlayer
local on = false
local Character = Player.Character or Player.CharacterAdded:Wait()
local Animator = Character:WaitForChild("Humanoid"):WaitForChild("Animator")
local idle = Animator:LoadAnimation(script.Parent:WaitForChild("Idle"))

script.Parent.Equipped:Connect(function()
    if Character then
        idle:Play()
    end
end)

script.Parent.Unequipped:Connect(function()
    if Character then
        idle:Stop()
    end
end)
2 Likes