Help with blocking script

i want to fix my blocking script.

error is
Players.kalersmot123.Backpack.Katana.Block:3: attempt to index nil with ‘WaitForChild’

here is a script:

local uis = game:GetService("UserInputService")
local hum = script.Parent.Parent.Parent:WaitForChild("Humanoid")

local walkspeed = 16
local blockingWalkspeed = walkspeed / 2

uis.InputBegan:Connect(function(key)
	if key.KeyCode == Enum.KeyCode.F then
		hum.WalkSpeed = blockingWalkspeed
		local animation = script.Parent.Animations.Block
		playAnimation = hum:LoadAnimation(animation)
		playAnimation:Play()
	end
end)

uis.InputEnded:Connect(function(key)
	if key.KeyCode == Enum.KeyCode.F then
		hum.WalkSpeed = walkspeed
		playAnimation:Stop()
	end
end)

where is the script located because the error says “script.parent.parent.parent” does not exist

guessing this is local script in a tool so you can change out this line with these to get the correct objects

local Player = game.Players.LocalPlayer
local Character = Player.Character or Player.CharacterAdded:Wait()
local hum = Character:WaitForChild('Humanoid')

in script which is located in tool

script is a server script and it is directly under the main Tool object?