Issues when ray casting to my target

I am getting lost here. I am trying to rework my system so it is not as laggy, right now, all I am doing is trying to make the rayCast on the client, but I seem to keep getting errors with the Target, would love some help, I can show you my current error, but every time I fix one thing it seems to break another.

Error 1: Attempt to connect failed: Passed value is not a function, Error 2: attempt to call a nil value

Most of my client sided code:

local function castRay(rTarget)

	--print("Target in castRay is set to"..rTarget)

	local laser_Thickness = .5

	local rayOriginPart = Eye
	local rayTargetPart = rTarget



	local origin = rayOriginPart.CFrame.Position
	local rayTarget = rayTargetPart.HumanoidRootPart.CFrame.Position
	local direction = (rayTarget - origin)

	local results = workspace:Raycast(origin, direction, RayCastParameters)

	if not results then
		results = {Position = rayTarget}
	end

	local distance = (results.Position - origin).Magnitude

	LaserPart.Size = Vector3.new(laser_Thickness,laser_Thickness,distance)


	LaserPart.CFrame = CFrame.new(origin, rayTarget) * CFrame.new(0,0, -distance / 2)


	--game.ReplicatedStorage.EyeEvent:FireAllClients(origin, rayTarget, distance, LaserPart)
end

local target

EyeEventRemote.OnClientEvent:Connect(function(Target)
	target = Target
	RunService.RenderStepped:Connect(castRay(target))
end)

Main part of server script:

function startGame()
	
	local Target = FindNearest()
	
	local TargetPrimaryPart = Target or Target.PrimaryPart
	
	
	EyeEventRemote:FireAllClients(Target)
	
	local Detector = Instance.new("Part")
	Detector.Anchored = true
	Detector.CanCollide = false
	Detector.Transparency = 0.5
	Detector.Color = Color3.fromRGB(255, 0, 0)
	Detector.Size = Vector3.new(1, 1, 1) * 4
	
end

I can provide more information if needed.

For the first error:

RunService.RenderStepped:Connect(castRay(target))

Connect() requires a function. You’ve put () after the “castRay” function, which causes it to run the function and return its result. Since the function doesn’t return anything, it returns nil. In the end your line of code looks like this:

RunService.RenderStepped:Connect(nil)

You should replace “castRay(target)” with “castRay”, but since you need to run the castRay function with an argument, you should do this instead:

RunService.RenderStepped:Connect(function()
	castRay(target)
end)

The 2nd error might also be due to the same problem as above.