Raycast Not Working On NPC

So i have an raycast script that when an player or Neutral NPC Is In-front, the Main Npc Speed Increases, but its not working, the Raycast Part Visualizer Disappears and appears every 7 seconds

Script:

task.wait(0.1)
local head = script.Parent:WaitForChild("Head")
local chrHum = script.Parent:WaitForChild("Humanoid")
local params = RaycastParams.new()
local filterTable = { head.Parent }
local playersInRange = {}
local radius = 25
local debris = game:GetService("Debris")
local IsAlreadySpeed = false

local function SpeedUp()
	print("Speeding UP")
   if IsAlreadySpeed then
		repeat wait(0.1) chrHum.WalkSpeed += 1 until chrHum.WalkSpeed >= 50
			print("Velocity Ended")
	end
end

local function SpeedDown()
	print("Speeding UP")
	if not IsAlreadySpeed then
		print("Speeding Down")
		chrHum.WalkSpeed = 16
	end
end

local function RayVisible(origin, direction)
	local midPoint = origin + direction/2
	
	local part = Instance.new("Part")
	part.Parent = script.Parent
	
	part.Anchored = true
	part.CanCollide = false
	part.CFrame = CFrame.new(midPoint, origin)
	part.Size = Vector3.new(.5,.5, direction.magnitude)
	
	part.Material = Enum.Material.Neon
	debris:AddItem(part, 0.15)
end

local function CreateRay()
	local origin = head.Position
	local stop = head.CFrame.LookVector * radius
	
	params.FilterDescendantsInstances = filterTable
	params.FilterType = Enum.RaycastFilterType.Blacklist
	local result = workspace:Raycast(origin, stop, params)
	RayVisible(origin, stop)
	
	if result then
		local hit = result.Instance
		if hit.Parent then
			local hm = hit.Parent:FindFirstChild("Humanoid")
			if hm then
				IsAlreadySpeed = true;
				playersInRange[hit.Parent] = tick()
				print("Humanoid Of "..hm.Parent.Name.." Found")
				SpeedUp()
			end
		end
	end
end

local function checkPlrTable()
	for char, t in pairs(playersInRange) do
		if tick() - playersInRange[char] >= 1 then
			playersInRange[char] = nil
			IsAlreadySpeed = false
			SpeedDown()
		end
	end
end

while task.wait() do
	CreateRay()
	checkPlrTable()
end

Photos:
image

When No NPC/Player Infront:

When Player/NPC Is Infront

image
After that seconds, everything repeats and repeats