Animation plays when tool isn't equipped

You can write your topic however you want, but you need to answer these questions:

  1. My friend gave me his tuck script to fix it cause the animation would also play if the animation isn’t equipped

  2. The animation plays when the player doesn’t have the tool equipped

  3. I don’t have any solutions currently

After that, you should include more details if you have any. Try to make your topic as descriptive as possible, so that it’s easier for people to help you!

The problem: robloxapp-20210226-1639409

The code:

local Character = player.Character or player.CharacterAdded:Wait()
local hum = player.Character:WaitForChild("Humanoid")

local KeyPressed = Enum.KeyCode.Q
local UIS = game:GetService("UserInputService")
local tuckanim = hum:LoadAnimation(script:WaitForChild("Tuck"))
local bar = script.Parent.LocalScript.BallGui.Power.PowerFrame.BarBackup.Bar

local values = script.Parent.Tuck

player.Character:FindFirstChild("Football")

UIS.InputBegan:Connect(function(Input, gameProcessedEvent)
	if Input.KeyCode == KeyPressed then
		values.Value = true
	else
		values.Value = false
		end
	end)
values.Changed:Connect(function()
	if values.Value == true then
		bar.ImageColor3 = Color3.new(0, 255, 0)
	else
		bar.ImageColor3 = Color3.new(195,0,0)
	end
end) ```

You need to make an Equipped and Activated function, so your code knows when the tool has actually equipped and activated while equipped. Right now you’ve just told it to play regardless if it is equipped or not. Look here for some help.

I had my friend look over it and I fixed it thank you for responding though

How did your friend go about fixing it?

He had to check if the player has the tool equipped. If its not equipped the animation can not play