Attempt to perform arithmetic (sub) on nil?

I have this raycasting script that casts a ray from one part to another, but it gives me the error attempt to perform arithmetic (sub) on nil

Here is my code

Client side

function CastRay()
	local spring = require(replicatedStorage.FrameWorkObjects.SpringModules.spring)
	
	
	local unit1 = viewer.Unit1
	local unit2 = viewer.Unit2
	
	local rayOrigin = unit1.Position
	local rayDestination = unit2.Position
	
	RemoteEventsFolder.FireEvent:FireServer(viewer.Unit1.Position, mouse.Hit.Position)
end

Here’s the server side

print("Ray script ready")
game.ReplicatedStorage.FrameWorkObjects.RemoteEvents.FireEvent.OnServerEvent:Connect(function(Player, FromP, ToP) --Error is on this line
	local RayCast = Ray.new(FromP,(ToP-FromP).unit*100)
	local Part,Position,Normal = game.Workspace:FindPartOnRay(RayCast,Player.Character, false, true)
	local Dist = (ToP-FromP).magnitude
	
	if not Dist then Dist = 300 end
	
	
	if Part and Part.Parent:FindFirstChild("Humanoid") and Part.Parent.Name ~= "Makarov" then
		Part.Parent.Humanoid:TakeDamage(40)
		local bloodParticle = game.ReplicatedStorage.BloodPart:Clone()
		
		bloodParticle.Position = Position
		bloodParticle.Parent = workspace
		
		game.Debris:AddItem(bloodParticle, 0.5)
	elseif Part and Part.Name == "Glass" then
		local shards = game.ReplicatedStorage.GlassShards:Clone()
		shards.Parent = workspace
		shards:SetPrimaryPartCFrame(Part.CFrame + Vector3.new(0, 3, 0))
		game.Debris:AddItem(shards, 10)
		Part:Destroy()
 	end
end)

Sorry if things aren’t properly formatted, I’m used to using Scripting Helpers

can you state the which line is producing the error, and not only the number.

Please look through the code. I have stated which line the error is coming from

I see it now, in the future please insert your code properly.