Raycasting not working

GetRemoteEvent("FireRifle").OnServerEvent:Connect(function(player, from, to, damage)
    local rayOrigin = from
    local rayDirection = to - from
    
    local raycastParams = RaycastParams.new();
    raycastParams.FilterDescendantsInstances = CollectionService:GetTagged("Rifle")
    raycastParams.FilterType = Enum.RaycastFilterType.Blacklist

    local raycastResult = workspace:Raycast(rayOrigin, rayDirection, raycastParams)

    if raycastResult then
        print("done.")
    end
end) 

Should be printing “done.” in the console but it isn’t. Running through the debugger all the variables are fine and the event is being fired, it’s just that raycastResult is nil. Why doesn’t this raycast work?

You might want to change rayDirection to 'to' from 'to - from' I guess, if 'to' is the position where your mouse is pointing at.

If you read the question closely you’ll see I said “the event is being fired.”

You’re right mb

Yeah I think it could be what @WilliamAlezandro said

It’s always the simplest things that work out. The wiki told me I have to do (origin - destination) or something but just changing it to “to” works now. thank you!