Help with coroutines

hi! Im trying to make a horror game right now, and I’m trying to do work on some enemyAI right now, but I’m having a little bit of trouble. Right now I have a movement function in a module script, and I’m trying to add in raycast detection, though I am a little stuck.

local RS = game:GetService("RunService")

local enemy = require(game.ReplicatedStorage:WaitForChild("EnemyAI"))

function raycast()
	local hum = script.Parent:WaitForChild("Humanoid")
	local hrp = script.Parent:WaitForChild("HumanoidRootPart")
	if hum then
		local raycastParams = RaycastParams.new()
		raycastParams.FilterDescendantsInstances = {script.Parent}
		raycastParams.FilterType = Enum.RaycastFilterType.Exclude
		local raycastResult = workspace:Raycast(
			script.Parent.HumanoidRootPart.Position, 
			Vector3.new(10, 10, 10) * hrp.CFrame.LookVector,
			raycastParams)
		print(Vector3.new(10, 10, 10) * hrp.CFrame.LookVector)
		if raycastResult then
			print(";hit")
		end
	end
end

RS.Stepped:Connect(function()
	--walk, if sees player print hit with raycast function
end)

since the movement is using moveto(pos).movedtofinished:wait(), it will wait until the thing finishes moving, then it will play the raycast function, but I want the raycast function to be playing at all times, even while its moving. Im pretty sure it has to do with coroutines, though I’m completely stuck with it. I tried reading the documentation and stuff like that but its all too complicated for my tiny brain to comprehend :frowning: any help would be greatly appreciated!
if you need access to the module script, feel free to let me know!