Animation won't play

Here is my code:

local UserInputServise = game:GetService("UserInputService")
local Character = script.Parent.Parent.Parent.Character
local Humanoid = Character:WaitForChild("Humanoid")
local isRunning = false
local Animation = Humanoid:LoadAnimation(script:WaitForChild("Animation"))
local EventTwo = game.ReplicatedStorage.ButtonPressed
local Presses = 0

UserInputServise.InputBegan:Connect(function(key)
    if key.KeyCode == Enum.KeyCode.T then
	    if not isRunning then
		    isRunning = true
		    Animation:Play()
		    Humanoid.WalkSpeed = 7
	    end
    end
end)
UserInputServise.InputEnded:Connect(function(key)
    if key.KeyCode == Enum.KeyCode.T then
	    isRunning = false
	    Animation:Stop()
	    Humanoid.WalkSpeed = 10
    end
end)

None of the below is needed.

script.Parent.Equipped:Connect(function()
    local EventOne = game.ReplicatedStorage.ShowGUI
    EventOne:FireServer()
end)

script.Parent.Unequipped:Connect(function()
    local EventOne = game.ReplicatedStorage.ShowGUI
    EventOne:FireServer()
end)

EventTwo.OnServerEvent:Connect(function()
    Presses = Presses + 1
    if Presses == 1 then
	    if not isRunning then
		    isRunning = true
		    Animation:Play()
		    Humanoid.WalkSpeed = 7
	    end
    else
	    if isRunning then
		    Presses = 0
		    isRunning = false
		    Animation:Stop()
		    Humanoid.WalkSpeed = 10
	    end
    end
end)

The code is inside of a tool that will be inside of the players backpack when this code runs.

What exactly are you trying to do here…? If this is a LocalScript, couldn’t you just define the Player as game.Players.LocalPlayer?

local UserInputServise = game:GetService("UserInputService")
local Player = game.Players.LocalPlayer
local Character = Player.Character or Player.CharacterAdded:Wait()
local Humanoid = Character:WaitForChild("Humanoid")
local isRunning = false
local Animation = Humanoid:LoadAnimation(script:WaitForChild("Animation"))
local EventTwo = game.ReplicatedStorage.ButtonPressed
local Presses = 0

UserInputServise.InputBegan:Connect(function(key)
    if key.KeyCode == Enum.KeyCode.T then
	    if not isRunning then
		    isRunning = true
		    Animation:Play()
		    Humanoid.WalkSpeed = 7
	    end
    end
end)
UserInputServise.InputEnded:Connect(function(key)
    if key.KeyCode == Enum.KeyCode.T then
	    isRunning = false
	    Animation:Stop()
	    Humanoid.WalkSpeed = 10
    end
end)

It is a server script. Why? Can it be a local script?

No, cause you’re getting the UserInputService which is only possible to use on LocalScripts only

You have to change it to a LocalScript if you want it to detect client key input

Maybe try this

local Player = script:FindFirstAncestorWhichIsA('Player')
local Character = Player.Character or Player.CharacterAdded:Wait()

Edit: Also if this is a server script then UserInputService can’t be used, make it a LocalScript.